· 6 years ago · Jul 23, 2019, 01:00 PM
1[Form]
2public class CF1_MySalesTable extends FormRun
3 implements SysIFilterConsumerForm, OfficeIMenuCustomizer
4{
5 #task
6 #Retail
7 boolean isCalledFromListPage;
8 SalesTableForm salesTableForm;
9 SalesTableType salesTableType;
10 SalesId newSalesId;
11
12 boolean isReturnFieldsEnabled;
13 //<GTH>
14 boolean isSalesTableExtensionTHEnabled;
15 //</GTH>
16 boolean isSalesTableWEnabled;
17 [FormObservable]
18 boolean isRetailOrder;
19 boolean updateSalesLineSourceId;
20
21 // Used for validateWrite and write to update tax groups on misc. charges and header2lines updates
22 DialogButton copyTaxGroupToMarkupTrans;
23 SalesTable2LineUpdatePrompt salesTable2LineUpdatePrompt;
24
25 QueryBuildRange queryBuildRangeProjId;
26 QueryBuildRange queryBuildRangeSalesId;
27
28 InventDimCtrl_Frm_Mov inventDimFormSetup;
29
30 SalesId oldSalesId;
31
32 boolean headerError;
33
34 QuotationId lastQuotation;
35 TransDate lastQuotationDate;
36 ConfirmId lastConfirm;
37 TransDate lastConfirmDate;
38 PackingSlipId lastPackingSlip;
39 TransDate lastPackingSlipDate;
40 InvoiceId lastInvoice;
41 TransDate lastInvoiceDate;
42 // MCR begin
43 boolean deleting, showSummaryDialog;
44 // MCR end
45
46 Object tmpSalesTableTaxTransForm;
47 // <GIN>
48 Object tmpSalesTableTaxWithholdTransForm;
49 boolean isIndiaIndirectTaxParameterMarked;
50 boolean isIndiaWHTMarked;
51 TaxExciseTypeController_IN taxExciseTypeController;
52 boolean isSalesLine_INEnabled;
53 boolean isIN;
54 // </GIN>
55
56 RecId interCompanyIsPriceDiscSearchNeeded;
57
58 boolean cashDiscOnInvoice;
59
60 Addressing oldThirdPartyBillingAddr;
61
62 boolean keepName; // When set to false Name is defaulted from category description.
63 LogisticsLocationRecId postalAddressLocation;
64
65 BankLCExportFeatureChecker bankLCExportFeatureChecker;
66 BankLGFeatureChecker bankLGFeatureChecker;
67 boolean enableLCFeature;
68 boolean enableLGFeature;
69
70 private static readonly container DeliveryLineImageData = ImageReference::constructForSymbol(ImageReferenceSymbol::DeliveryLine).pack();
71 private static readonly container OrderLineMultipleDeliveriesImageData = ImageReference::constructForSymbol(ImageReferenceSymbol::OrderLineMultipleDeliveries).pack();
72
73 InventItemBarcode itemBarcode;
74 // <GEERU>
75 boolean isRU;
76 Map itemInventDimSetupCache;
77 #ISOCountryRegionCodes
78 // </GEERU>
79
80 DueDate priorDueDate;
81
82 // <GBR>
83 SalesPurchOperationTypeController_BR salesPurchOperationTypeController_BR;
84 // </GBR>
85 // <GEEU>
86 boolean countryRegion_EEU;
87 // </GEEU>
88
89 //<GTH>
90 boolean isUnrealizedVATEnabled;
91 //</GTH>
92 // <GEEPL>
93 boolean countryRegion_PL;
94 // </GEEPL>
95
96 boolean skipLinkActive;
97 boolean linkActiveHeaderExecuted;
98 // Variables used to communicate between CustomerService and SalesTable
99 MCRCustomerServiceParam mcrCustomerServiceParm;
100 SalesCreateOrderForm salesCreateOrderForm;
101 // Source Code
102 MCRSourceID mcrLastSourceId;
103 // Price override needs to save values off depending on whether it is
104 // a price override, or the user is turning off an override. These values will be
105 // used to write an order event.
106 MCROrderEventType mcrLinePriceOverrideEventType;
107 RetailInformationSubcodeId mcrLinePriceOverrideReasonCode;
108 UserId mcrLinePriceOverrideUserId;
109 // Similar to line price override values above, but for header override.
110 MCROrderEventType mcrHeaderPriceOverrideEventType;
111 RetailInformationSubcodeId mcrHeaderPriceOverrideReasonCode;
112 UserId mcrHeaderPriceOverrideUserId;
113 SalesEndDiscPct mcrHeaderPriceOverrideDiscPct;
114 // track open orders that have been modified
115 SalesTable openOrderSalesTable;
116 // The source code script is comprised of strings coming from code
117 // launched from multiple locations. This variable stores the concatenation
118 // of these strings.
119 str sourceCodeScripts;
120 boolean enterOrderFromNewCust;
121 // Determine which shipto tab to make active when switching records
122 boolean shipToTabActive;
123 boolean advanced;
124 // map to store the available quantity.
125 Map availableQtyMap;
126 // Used to signify form is called by Returns
127 boolean returnProcessing;
128 // Variables needed to have personalization execute correctly
129 boolean executePersonalization;
130 QueryBuildRange queryRange;
131 QueryBuildRange queryQtyRange;
132 QueryBuildRange queryOptionsRefRange;
133 QueryBuildRange queryGroupRange;
134 InventQty salesLineMaxQty;
135 int64 curQty;
136 boolean inTextLine;
137 boolean onInit;
138 boolean fromQty;
139 boolean fromLostControl;
140 boolean itemChanged;
141 Map map;
142 boolean blockSalesLineDelete;
143 boolean mcrProcessingDeliverySchedule;
144 // Used to track when to update the MCRScriptText
145 int mcrSkipScript;
146 // Margin Alerts
147 Map marginMap;
148 // Script
149 MCRNotes mcrScript;
150 MCRSalesTableConfigure salesTableConfigure;
151 MCROrderParameters mcrOrderParameters;
152 RetailMCRChannelTable retailMCRChannelTable;
153 NoYes enableDirectedSelling;
154 NoYes enableOrderCompletion;
155 NoYes enableOrderPriceControl;
156 CustParameters custParameters;
157 SalesParameters salesParameters;
158 boolean mcrParmsSet;
159 boolean mcrCallCenterEnabled;
160 boolean mcrCallCenterOrder;
161 boolean mcrGiftCardPoliciesEnabled;
162 boolean mcrProcessGiftCardsAsPrepayments_RU;
163 SysExtensionSerializerFormRunHelper formRunHelper;
164 MCRSalesOrderGiftCardPolicyHelper giftCardPolicyCache;
165
166 UnknownNoYes performIntercompanyValidationCache;
167 boolean inDeleteMarked;
168 // <GMY>
169 boolean isIsoMY;
170 boolean isSalesLineWEnabled;
171 boolean isWrnPrintedMY;
172 CustInvoiceJourLookupController_MY custInvoiceJourLookupController;
173 EcoResShowDisplayProductNumber showDisplayProductNumber;
174 // </GMY>
175
176 ReverseCharge_W reverseCharge;
177
178 InventDistinctProduct productFromLookup;
179 boolean isProductSearchLookupEnabled;
180 boolean isAnyNonApprovedLine;
181
182 #define.taskClearFfilter(2840)
183 SalesId newButtonCurrentSalesId;
184 int taskId;
185
186 /// <summary>
187 /// Performs additional actions when the sales order is created.
188 /// </summary>
189 protected void salesTableCreated()
190 {
191 if (isRU)
192 {
193 salesTable_RU.data(SysExtensionSerializerExtensionMap::findByBase(salesTable_RU.TableId,
194 salesTable.RecId,
195 true));
196 salesTable_RU_DS.rereadReferenceDataSources();
197 }
198
199 if (BrazilParameters::isEnabled())
200 {
201 salesTable_BR.data(SysExtensionSerializerExtensionMap::findByBase(salesTable_BR.TableId,
202 salesTable.RecId,
203 true));
204
205 salesTable_BR_DS.rereadReferenceDataSources();
206 }
207
208 if (isRU || BrazilParameters::isEnabled())
209 {
210 salesTable_ds.refresh();
211 }
212
213 if (isSalesTableExtensionTHEnabled)
214 {
215 salesTable_DS.research(true);
216 }
217
218 if (isSalesTableWEnabled)
219 {
220 salesTable_W.data(SysExtensionSerializerExtensionMap::findByBase(salesTable_W.TableId,
221 salesTable.RecId,
222 true));
223
224 salesTable_W_DS.rereadReferenceDataSources();
225 salesTable_DS.refresh();
226 }
227 }
228
229 /// <summary>
230 /// Customizes the options used to populate the Office Menu with the sales order entities.
231 /// </summary>
232 /// <param name = "_menuOptions">The menu options to be customized.</param>
233 public void customizeMenuOptions(OfficeMenuOptions _menuOptions)
234 {
235 ListIterator dataEntityOptionsIterator = new ListIterator(_menuOptions.dataEntityOptions());
236
237 while (dataEntityOptionsIterator.more())
238 {
239 OfficeMenuDataEntityOptions dataEntityOptions = dataEntityOptionsIterator.value();
240
241 DictDataEntity dataEntity = new DictDataEntity(tablename2Id(dataEntityOptions.dataEntityName()));
242
243 if (dataEntity.formRef() == menuItemDisplayStr(ReturnTableDetails))
244 {
245 dataEntityOptionsIterator.delete();
246 }
247 else
248 {
249 dataEntityOptionsIterator.next();
250 }
251 }
252 }
253
254 /// <summary>
255 /// Delegate raised before calling to super when writing the <c>SalesLine</c> data source.
256 /// </summary>
257 delegate void salesLineDataSourceWriting(SalesLine _salesLine)
258 {
259 }
260
261 /// <summary>
262 /// Delegate raised after writing the <c>SalesLine</c> data source.
263 /// </summary>
264 delegate void salesLineDataSourceWritten(SalesLine _salesLine, SalesStatus _originalSalesStatus)
265 {
266 }
267
268 /// <summary>
269 /// This method allows or restricts editing of the <c>Issue own certificate</c> field
270 /// depending on the value of the <c>Entry certificate required</c> field.
271 /// </summary>
272 void allowEditIssueOwnEntryCertificate_W()
273 {
274 salesTable_W_ds.object(fieldNum(SalesTable_W, IssueOwnEntryCertificate_W)).allowEdit(salesTable_W.EntryCertificateRequired_W);
275 }
276
277 /// <summary>
278 /// Confirms updating reason code on sales lines.
279 /// </summary>
280 /// <returns>true if confirmed; otherwise, false.</returns>
281 [Replaceable]
282 protected boolean confirmReasonCodeUpdateOnLines()
283 {
284 return Box::yesNo(strFmt("@GLS220468", "@GLS104580"), DialogButton::Yes) == DialogButton::Yes;
285 }
286
287 /// <summary>
288 /// Confirms updating reason comment on sales lines.
289 /// </summary>
290 /// <returns>true if confirmed; otherwise, false.</returns>
291 [Replaceable]
292 protected boolean confirmReasonCommentUpdateOnLines()
293 {
294 return Box::yesNo(strFmt("@GLS220468", "@SYS114149"), DialogButton::Yes) == DialogButton::Yes;
295 }
296
297 /// <summary>
298 /// Confirms updating source id on sales lines.
299 /// </summary>
300 /// <returns>true if confirmed; otherwise, false.</returns>
301 [Replaceable]
302 protected boolean confirmSourceIdUpdateOnLines()
303 {
304 return Box::yesNo(strFmt("@SYS311966", strFmt("@SYS62836", fieldStr(MCRSalesTable, SourceId)), "@SYS79387"), DialogButton::Yes) == DialogButton::Yes;
305 }
306
307 public void registerDatasourceOnQueryingEvent()
308 {
309 salestable_ds.OnQueryExecuting += eventhandler(this.parmFilterFormQueryEventHandler().applyFilter);
310 }
311
312 boolean allowEditLedgerAccount_RU()
313 {
314 boolean allowEdit;
315
316 if (itemInventDimSetupCache && salesLine.ItemId)
317 {
318 if (itemInventDimSetupCache.exists(salesLine.ItemId))
319 {
320 allowEdit = itemInventDimSetupCache.lookup(salesLine.ItemId);
321 }
322 else
323 {
324 allowEdit = ! EcoResDimensionGroupSetup::isInventoryDimensionActiveForItem(salesLine.ItemId,
325 fieldNum(InventDim, InventProfileId_RU));
326 itemInventDimSetupCache.insert(salesLine.ItemId, allowEdit);
327 }
328 }
329
330 return allowEdit;
331 }
332
333 public void automaticTotalDiscount()
334 {
335 if (CustParameters::find().AutomaticTotalDiscount)
336 {
337 salesTable.updateFinalDisc();
338 // CreditLimit calculation should only be triggered if updateFinalDisc() changes the DiscPercent which is indicated by touched.
339 // save the value since it is lost by reread().
340 if (salesTable.Touched)
341 {
342 // Reread the buffer since updateFinalDisc() can call update().
343 salesTable_ds.reread();
344 salesTable_ds.refresh();
345 // This will trigger the credit limit calculation when salesTable.validateWrite is called.
346 salesTable_ds.setTouched();
347 }
348 }
349 }
350
351 public boolean canClose()
352 {
353 boolean ret;
354
355 // We need to set openOrderSalestable in cases where we use copying and records get saved on different form. In those cases, this variable is not getting set
356 // and hence it cannot enforce payment screen. A check has been added for salesline existence to make sure that sales order has at least one or more lines
357 // before this variable is set as there are cases related to remove lines after adding in which case we would let customer exit the order without making a payment
358 if (salesTable.SalesStatus == SalesStatus::Backorder
359 && enableOrderCompletion)
360 {
361 boolean salesLineExists = SalesLine::exist(salesTable.SalesId);
362 if (salesLineExists)
363 {
364 openOrderSalesTable = salesTable.data();
365 }
366 else
367 {
368 openOrderSalesTable = null;
369 }
370 }
371
372 // The user needs to be able to modify an exchange order associated to a return and
373 // go back to returns without completing the exchange order (this order). The returns
374 // logic will prevent the order from remaining open. A return must always be completed
375 // therefore, the exchange order will never be left open.
376 ret = element.mcrCheckOpenOrder();
377
378 if (element.closedCancel() && ret)
379 {
380 ret = salesTableForm.canClose(salesTable);
381 }
382
383 ret = ret && super();
384
385 return ret;
386 }
387
388 void changeType()
389 {
390 if (salesTableType)
391 {
392 salesTableType.formMethodSalesTypeModifiedPreChange(element, salesTable_ds, true);
393 }
394
395 salesTableType = salesTable.type();
396
397 salesTableType.formMethodSalesTypeModifiedPostChange(element, salesTable_ds, true);
398
399 salesTableForm.enableAvailableDlvDatesButtons(salesTable,
400 salesAvailableDlvDatesHeader,
401 salesAvailableDlvDatesLine,
402 salesLine.LineDeliveryType);
403 element.configBankDocumentControls();
404 // <GEERU>
405 if (isRU)
406 {
407 salesTable_ds.object(fieldNum(SalesTable_RU, AgreementHeaderExt_RU)).allowEdit(salesTableType.canAgreementBeLinked());
408 }
409 // </GEERU>
410 }
411
412 void checkCreditNoteLine()
413 {
414 // Additional check of returned item disables all these fields, if the -ve qty salesline is of type returned item.
415 boolean creditNote = salesLine.SalesQty && salesLine.creditNoteLine(salesTable) && !salesTable.returnItem();
416
417 boolean editCostPrice = !salesLine.InventTransIdReturn || !InventTable::find(salesLine.ItemId).modelGroup().inventModelType().stdCostBased();
418
419 salesLine_ds.object(fieldNum(SalesLine, Scrap)).allowEdit(creditNote && salesLine.deliveredInTotal() == 0);
420 salesLine_ds.object(fieldNum(SalesLine, Scrap)).skip(!creditNote);
421
422 salesLine_ds.object(fieldNum(SalesLine, InventTransIdReturn)).allowEdit(creditNote);
423 salesLine_ds.object(fieldNum(SalesLine, InventTransIdReturn)).skip(!creditNote);
424
425 salesLine_ds.object(fieldNum(SalesLine, CostPrice)).allowEdit((creditNote && editCostPrice));
426 salesLine_ds.object(fieldNum(SalesLine, CostPrice)).skip(!(creditNote && editCostPrice));
427
428 if (salesLine.Scrap && salesLine.SalesQty >= 0)
429 {
430 salesLine.Scrap = NoYes::No;
431 }
432 // <GIN>
433 if (isIndiaIndirectTaxParameterMarked && !salesTable.returnItem())
434 {
435 salesLineReturnDetails_IN_ds.object(fieldNum(SalesLineReturnDetails_IN, Type)).allowEdit(creditNote);
436 salesLineReturnDetails_IN_ds.object(fieldNum(SalesLineReturnDetails_IN, BasisType)).allowEdit(salesLineReturnDetails_IN.Type != SalesReturnType_IN::None);
437 salesLineReturnDetails_IN_ds.object(fieldNum(SalesLineReturnDetails_IN, Period)).allowEdit(salesLineReturnDetails_IN.Type != SalesReturnType_IN::None);
438 salesLineReturnDetails_IN_ds.object(fieldNum(SalesLineReturnDetails_IN, PeriodType)).allowEdit(salesLineReturnDetails_IN.Type != SalesReturnType_IN::None);
439 }
440 // </GIN>
441 }
442
443 void close()
444 {
445 xSysLastValue::saveLast(salesTableForm);
446
447 // Current price references may need to be deleted.
448 salesLine.salesPurchLineInterface().cleanUpPriceHistoryRef();
449
450 if (salesTableType)
451 {
452 salesTableType.formMethodClose();
453 }
454
455 super();
456 }
457
458 /// <summary>
459 /// Configures the BankDocument Controls.
460 /// </summary>
461 public void configBankDocumentControls()
462 {
463 boolean enableDocumentType = false;
464
465 if (enableLCFeature
466 || enableLGFeature)
467 {
468 enableDocumentType = salesTable.type().mayBankDocumentTypeBeModified();
469 element.configPaymentGroupControls();
470 salesTable_DS.object(fieldNum(SalesTable, BankDocumentType)).allowEdit(enableDocumentType);
471 }
472 }
473
474 /// <summary>
475 /// Configures the payment group controls.
476 /// </summary>
477 private void configPaymentGroupControls()
478 {
479 boolean flag;
480
481 flag = !salesTable.isMarkedForBankLC();
482
483 salesTable_DS.object(fieldNum(SalesTable, Payment)).enabled(flag);
484 salesTable_DS.object(fieldNum(SalesTable, FixedDueDate)).enabled(flag);
485 salesTable_DS.object(fieldNum(SalesTable, PaymMode)).enabled(flag);
486 salesTable_DS.object(fieldNum(SalesTable, PaymSpec)).enabled(flag);
487 salesTable_DS.object(fieldNum(SalesTable, PaymentSched)).enabled(flag);
488 salesTable_DS.object(fieldNum(SalesTable, CashDisc)).enabled(flag);
489 salesTable_DS.object(fieldNum(SalesTable, SettleVoucher)).enabled(flag);
490
491 payment_M_editCreditCard.enabled(flag);
492 }
493
494 public void createAgreementLink()
495 {
496 AgreementLine localAgreementLine;
497 Args args;
498 FormRun formRun;
499 SalesTableForm_DlvScheduleSyncEnabled salesTableFormDlvSchedule;
500 SalesLine origSalesLine;
501
502 args = new Args(formStr(AgreementLinePrompt));
503 args.caller(element);
504 args.record(salesLine);
505 args.parm(int642str(salesTable.MatchingAgreement));
506 formRun = classfactory.formRunClass(args);
507 formRun.init();
508 formRun.run();
509 formRun.wait(true);
510 localAgreementLine = args.record() as AgreementLine;
511
512 if (localAgreementLine)
513 {
514 // Make the snapshot of the salesLine before it gets associated with agreement
515 origSalesLine = salesLine.data().orig();
516
517 ttsbegin;
518
519 SalesTableForm::createAgreementLinkServer(salesLine, localAgreementLine);
520
521 if (salesLine.LineDeliveryType == LineDeliveryType::OrderLineWithMultipleDeliveries)
522 {
523 salesTableFormDlvSchedule = salesTableForm as SalesTableForm_DlvScheduleSyncEnabled;
524 salesTableFormDlvSchedule.parmOrderLineOrig(origSalesLine);
525 if (salesTableFormDlvSchedule.deliveryLinesSync(salesLine, false))
526 {
527 // Need to refresh delivery lines on grid.
528 salesLine_DS.executeQuery();
529 }
530 }
531
532 ttscommit;
533 // <GEERU>
534 salesLine_DS.research(true);
535 // </GEERU>
536
537 //Re-evaluate agreement line actions
538 element.enableLineAgreementActions();
539 }
540 }
541
542 public Common docCursor()
543 {
544 Common docCursor;
545
546 docCursor = super();
547
548 if (docCursor.TableId == tableNum(InventDim))
549 {
550 docCursor = salesLine;
551 }
552
553 return docCursor;
554 }
555
556 void doRefresh(boolean _lineRefreshNeeded = false)
557 {
558 salesTable_ds.reread();
559 salesTable_ds.refresh();
560
561 retailSalesTable_ds.reread();
562 retailSalesTable_ds.refresh();
563
564 mcrSalesTable_ds.reread();
565 mcrSalesTable_ds.refresh();
566
567 mcrSalesTableShipping_ds.reread();
568 mcrSalesTableShipping_ds.refresh();
569
570 // update header controls
571 element.mcrSetHeaderControls();
572 if (_lineRefreshNeeded)
573 {
574 salesLine_ds.reread();
575 salesLine_ds.refresh();
576 }
577 else
578 {
579 // With addition of executeQuery (see below) base call to research is not needed
580 // salesLine_ds.reread() fails if a new, unsaved, line exists.
581 // Changed to perform a new query, which will retrieve all saved lines.
582 // The new query will cause line controls to be updated.
583 salesLine_ds.executeQuery();
584 }
585 }
586
587 public void editSales(boolean _allowEdit, boolean _allowDelete = _allowEdit)
588 {
589 salesTable_ds.allowEdit (_allowEdit);
590 salesTable_ds.allowDelete (_allowEdit && _allowDelete);
591 // allow user to delete the exchange
592 if ( mcrReturnSalesTable.IsExchange
593 && mcrCallCenterEnabled)
594 {
595 salesTable_ds.allowDelete (true);
596 }
597 salesLine_ds.allowEdit (_allowEdit);
598 salesLine_ds.allowCreate (_allowEdit);
599 salesLine_ds.allowDelete (_allowEdit && _allowDelete);
600
601 // <GBR>
602 if (BrazilParameters::isEnabled())
603 {
604 salesTable_BR_DS.enableDataSourceFields_BR();
605 buttonLineQuickQuote.enabled(_allowEdit);
606 if (isConfigurationkeyEnabled(configurationKeyNum(Retail)))
607 {
608 retailAddItemMenuItem.enabled(_allowEdit);
609 }
610 }
611 // </GBR>
612 element.mcrSetLineControls();
613 }
614
615 public void enableEximInquiry_IN()
616 {
617 if (EximAuthorizationSchemesTable_IN::enableSchemesButton(salesLine.RecId,
618 EximAuthorizationType_IN::AA,
619 EximAuthorizationBasis_IN::Purchase)
620 || salesLine.SalesQty < 0)
621 {
622 eximAA_IN.enabled(false);
623 }
624 if (EximAuthorizationSchemesTable_IN::enableSchemesButton(salesLine.RecId,
625 EximAuthorizationType_IN::DFIA,
626 EximAuthorizationBasis_IN::Purchase)
627 || salesLine.SalesQty < 0)
628 {
629 eximDFIA_IN.enabled(false);
630 }
631 }
632
633 public void enableFieldsActive_IN()
634 {
635 customsExportAssessableValue_IN.enabled(salesTable.CustomsExportOrder_IN == NoYes::Yes && TaxParameters::find().Customs_IN == NoYes::Yes);
636 salesLine_CustomsMaxRetailPrice_IN.visible(salesTable.CustomsExportOrder_IN == NoYes::Yes && TaxParameters::find().Customs_IN == NoYes::Yes);
637 salesLine_MaximumRetailPrice_IN.enabled(salesTable.CustomsExportOrder_IN == NoYes::No);
638
639 element.setEximFieldsAccess_IN();
640 }
641
642 public void enableForeignTrade_RU()
643 {
644 salesLine_ds.object(fieldNum(SalesLine, InvoiceGTDId_RU)).enabled(
645 salesLine_ds.object(fieldNum(SalesLine, CountryRegionName_RU)).enabled(! salesLine.isStocked())
646 );
647 }
648
649 /// <summary>
650 /// Sets the status of header level credit card menu items.
651 /// </summary>
652 public void enableHeaderCreditCardMenuItems()
653 {
654 SalesTableInteractionHelper salesTableInteractionHelper = SalesTableInteractionHelper::construct();
655
656 salesTableInteractionHelper.initLineActions(salesTable, salesLine);
657
658 creditCardPreauthorize.enabled(salesTableInteractionHelper.parmCanCreditCardPreAuthorizeEnabled());
659 creditCardWizard.enabled(salesTableInteractionHelper.parmCreditCardWizardEnabled());
660 }
661
662 /// <summary>
663 /// Sets the status of header credit card menu items.
664 /// </summary>
665 /// <remarks>
666 /// Invoked whenever a link to an agreement is created or removed for the order line line.
667 /// </remarks>
668 public void enableLineAgreementActions()
669 {
670 SalesTableInteractionHelper salesTableInteractionHelper = SalesTableInteractionHelper::construct();
671
672 salesTableInteractionHelper.initLineActions(salesTable, salesLine);
673 salesTableInteractionHelper.setSalesTableForm(salesTableForm);
674
675 salesAgreementLine.enabled(salesTableInteractionHelper.parmAgreementLineEnabled());
676 createLink.enabled(salesTableInteractionHelper.parmAgreementCreateLinkEnabled());
677 removeLink.enabled(salesTableInteractionHelper.parmAgreementRemoveLinkEnabled());
678 }
679
680 /// <summary>
681 /// Disables fields that should not be edited once Route Plan has been selected.
682 /// </summary>
683 public void enableTMSFields()
684 {
685 TMSTransportationTemplateId transTempId;
686 TMSCarrierCode carrierCode;
687 TMSCarrierGroupCode carrierGroupCode;
688 TMSModeCode modeCode;
689 TMSRouteConfigCode routeConfigCode;
690 boolean modeCodeDisabled;
691
692 transTempId = tmsSalesTable.TransportationTemplateId;
693 carrierCode = tmsSalesTable.CarrierCode;
694 carrierGroupCode = tmsSalesTable.CarrierGroupCode;
695 modeCode = tmsSalesTable.ModeCode;
696 modeCodeDisabled = tmsSalesTable.ModeCode != '' && tmsSalesTable.CarrierCode == '';
697 routeConfigCode = tmsSalesTable.RouteConfigCode;
698
699 tmsSalesTable_ds.object(fieldNum(TMSSalesTable, ModeCode)).allowEdit(!(carrierCode || transTempId || carrierGroupCode || routeConfigCode));
700 tmsSalesTable_ds.object(fieldNum(TMSSalesTable, CarrierCode)).allowEdit(!(transTempId ||carrierGroupCode || modeCodeDisabled || routeConfigCode));
701 tmsSalesTable_ds.object(fieldNum(TMSSalesTable, CarrierServiceCode)).allowEdit(!(transTempId || carrierGroupCode || modeCodeDisabled || routeConfigCode));
702 tmsSalesTable_ds.object(fieldNum(TMSSalesTable, CarrierGroupCode)).allowEdit(!(transTempId || carrierCode || routeConfigCode || modeCode));
703 tmsSalesTable_ds.object(fieldNum(TMSSalesTable, RouteConfigCode)).allowEdit(!(carrierCode || transTempId || modeCode || carrierGroupCode));
704 tmsSalesTable_ds.object(fieldNum(TMSSalesTable, TransportationTemplateId)).allowEdit(!(carrierCode || carrierGroupCode || modeCode || routeConfigCode));
705 }
706
707 /// <summary>
708 /// Constructs an instance of the <C>SysExtensionSerializerFormRunHelper</C> class.
709 /// </summary>
710 /// <returns>
711 /// An instance of the <C>SysExtensionSerializerFormRunHelper</C> class.
712 /// </returns>
713 public SysExtensionSerializerFormRunHelper formRunHelper()
714 {
715 if (!formRunHelper)
716 {
717 formRunHelper = SysExtensionSerializerFormRunHelper::construct();
718 }
719
720 return formRunHelper;
721 }
722
723 void gotoLines()
724 {
725 salesLineGrid.setFocus();
726 }
727
728 void hideQualityManagement()
729 {
730 salesTable_qualityOrderStatusDisplay.visible(false);
731 salesLineStatus_qualityOrderStatus.visible(false);
732 status_qualityOrderStatusDisplay.visible(false);
733 salesLine_QualityOrderStatus.visible(false);
734
735 inventNonConformanceTableHeader.visible(false);
736 inventQualityOrderTableHeader.visible(false);
737 inventNonConformanceTableLine.visible(false);
738 inventQualityOrderTableLine.visible(false);
739 inventTestCertOfAnalysisTable.visible(false);
740
741 lineStripProductQualitySeparator.visible(false);
742 }
743
744 public void findProductNumber()
745 {
746 if (showDisplayProductNumber)
747 {
748 inventDistinctProductExpanded.data(inventDistinctProductExpanded::findByInventDim(SalesLine.ItemId, inventDim));
749 inventDistinctProductExpanded_ds.setCurrent();
750 }
751 }
752
753 public void init()
754 {
755 EnumId initialMenuItemArgsEnumId;
756 SalesTableFormId initialMenuItemArgsFormId = SalesTableFormId::None;
757 FormRun initialFormRun;
758 Common initialFormRunRecord;
759 boolean enableConfigurationFeature = PCRuntimeLibrary::isConfigurationKeyEnabled();
760 isProductSearchLookupEnabled = EcoResProductSearchLookup::isProductSearchLookupEnabled();
761
762 RetailParameters retailParameters;
763
764 #ISOCountryRegionCodes
765
766 custParameters = CustParameters::find();
767
768 // <GMY>
769 isIsoMY = TaxGSTFeatureChecker_MY::isCountryRegionMY();
770 if (isIsoMY)
771 {
772 custInvoiceJourLookupController = CustInvoiceJourLookupController_MY::construct();
773 isWrnPrintedMY = false;
774 }
775 // </GMY>
776
777 // <GIN>
778 isIN = SysCountryRegionCode::isLegalEntityInCountryRegion([#isoIN]);
779 if (isIN)
780 {
781 isIndiaIndirectTaxParameterMarked = TaxParameters::checkTaxParameters_IN();
782 isIndiaWHTMarked = TaxWithholdParameters_IN::checkTaxParameters();
783 isSalesLine_INEnabled = SysExtensionSerializerExtensionMap::isExtensionEnabled(tableNum(SalesLine_IN));
784 }
785 // </GIN>
786
787 // <GEERU>
788 // has to be before super to be used in methods such as FormDataSource.init()
789 isRU = SysCountryRegionCode::isLegalEntityInCountryRegion([#isoRU]);
790 // </GEERU>
791 // <GEEPL>
792 countryRegion_PL = SysCountryRegionCode::isLegalEntityInCountryRegion([#isoPL]);
793 // </GEEPL>
794
795 isCalledFromListPage = TradeFormHelper::isCalledFromForm(element.args(), formStr(SalesTableListPage));
796
797 if (element.args())
798 {
799 if (isCalledFromListPage)
800 {
801 initialFormRun = element.args().caller() as FormRun;
802 }
803 else
804 {
805 element.args().copyCallerQuery(CopyCallerQuery::No);
806
807 initialFormRun = element;
808 }
809
810 if (initialFormRun)
811 {
812 initialMenuItemArgsEnumId = initialFormRun.args().parmEnumType();
813
814 if (initialMenuItemArgsEnumId == enumNum(SalesTableFormId))
815 {
816 initialMenuItemArgsFormId = initialFormRun.args().parmEnum();
817 }
818
819 initialFormRunRecord = initialFormRun.args().record();
820 }
821 }
822
823 if (element.args().caller() is SysIFilterProvider)
824 {
825 element.args().lookupRecord(null);
826 element.args().record(null);
827 }
828
829 super();
830
831 // <GEERU>
832 if (isRU)
833 {
834 itemInventDimSetupCache = new Map(Types::String, Types::Enum);
835 }
836 // </GEERU>
837 // <GEEU>
838 countryRegion_EEU = SysCountryRegionCode::isLegalEntityInCountryRegion([#isoLT, #isoLV, #isoEE, #isoCZ, #isoPL, #isoHU, #isoRU]);
839 // </GEEU>
840
841 // Initialization specifically for projects
842 // Only show sales orders associated to projects if form is called from the project main menu
843 if (initialMenuItemArgsEnumId == enumNum(SalesTableFormId) && initialMenuItemArgsFormId == SalesTableFormId::Project)
844 {
845 if (! element.args().record()) // called from menu
846 {
847 salesTable_ds.query().dataSourceTable(tableNum(SalesTable)).addRange(fieldNum(SalesTable, ProjId)).value(SysQuery::valueNotEmptyString());
848 }
849 }
850
851 // Initialization specifically for Journals
852 // Do not allow order type change if form was called from Sales journal menu items
853 if (initialMenuItemArgsEnumId == enumNum(SalesTableFormId) && initialMenuItemArgsFormId == SalesTableFormId::Journal)
854 {
855 salesTable_ds.object(fieldNum(SalesTable, SalesType)).allowEdit(false);
856 salesTable_SalesType.allowEdit(false);
857 }
858
859 if (initialMenuItemArgsEnumId == enumNum(SalesTableFormId))
860 {
861 salesTableForm = SalesTableForm::construct(initialMenuItemArgsFormId, initialFormRunRecord);
862 }
863 else
864 {
865 salesTableForm = SalesTableForm::construct(SalesTableFormId::None, element.args().record());
866 }
867
868 // Update group separator visibility...
869 // (group contains a single button)
870 lineStripFinancialsIntroduceSeparator.visible(
871 buttonCustVendCreditInvoicingLines.isVisible());
872
873 // TaxVATNumTable::enableLookupVATNum(vatNum);
874
875 element.updateDesign(InventDimFormDesignUpdate::Init);
876
877 salesTable_ds.object(fieldNum(SalesTable, SalesType)).allowEdit(salesTableForm.editSalesType());
878
879 salesTable_ds.query(salesTableForm.querySalesTable(salesTable_ds.query()));
880 salesLine_ds.query(salesTableForm.querySalesLine(salesLine_ds.query()));
881
882 //groupNotificationToTheCentralBank.visible(SysCountryRegionCode::isLegalEntityInCountryRegion([#isoNO]));
883
884 if (!TaxParameters::find().CashDiscOnInvoice)
885 {
886 salesTable_ds.object(fieldNum(SalesTable, CashDiscPercent)).allowEdit(false);
887 }
888
889 if (!InventParameters::find().UseQualityManagement)
890 {
891 element.hideQualityManagement();
892 }
893 mcrOrderParameters = MCROrderParameters::find();
894 salesParameters = SalesParameters::find();
895 mcrCallCenterEnabled = MCROrderParameters::isCallCenterEnabledAndInUse();
896
897 if (mcrCallCenterEnabled)
898 {
899 retailParameters = RetailParameters::find();
900 mcrGiftCardPoliciesEnabled = retailParameters.UseGiftCardPolicies;
901 mcrProcessGiftCardsAsPrepayments_RU = retailParameters.ProcessGiftCardsAsPrepayments_RU;
902 }
903
904 // Initiate the map used to store the available quantity
905 availableQtyMap = new Map(Types::String, Types::Real);
906
907 onInit = true;
908 map = new Map(Types::Integer, Types::String);
909 this.enableHeaderCreditCardMenuItems();
910 mcrMarginAlert.visible(salesParameters.mcrEnableMarginAlert);
911 mcrMarginPercentStr.visible(salesParameters.mcrEnableMarginAlert);
912 McrMarginPercentSalesLineUpdate.visible(salesParameters.mcrEnableMarginAlert);
913 element.resetMarginMap();
914 mcrPriceHistory.visible(custParameters.mcrEnablePriceDetails);
915
916 bankLGFeatureChecker = BankLGFeatureChecker::construct();
917 enableLGFeature = bankLGFeatureChecker.checkFeatureEnabled();
918 bankLGRequestForm.visible(enableLGFeature);
919
920 bankLCExportFeatureChecker = BankLCExportFeatureChecker::construct();
921 enableLCFeature = bankLCExportFeatureChecker.checkFeatureEnabled();
922 salesTable_DS.object(fieldNum(SalesTable, BankDocumentType)).visible(enableLCFeature || enableLGFeature);
923 buttonCreateBankLCExport.visible(enableLCFeature);
924
925 pcExecute.visible(enableConfigurationFeature);
926
927 //<GMX>
928 if (SysCountryRegionCode::isLegalEntityInCountryRegion([#isoMX]))
929 {
930 this.updateDesign_MX();
931 }
932 //</GMX>
933
934 // Needed to check validity of address
935 logisticsPostalAddressDeliveryHeader_ds.addFieldToSelectionList(fieldNum(LogisticsPostalAddress, ValidFrom));
936 logisticsPostalAddressDeliveryHeader_ds.addFieldToSelectionList(fieldNum(LogisticsPostalAddress, ValidTo));
937 logisticsPostalAddressDeliveryHeader_ds.addFieldToSelectionList(fieldNum(LogisticsPostalAddress, CountryRegionId));
938 logisticsPostalAddressShipCarrierHeader_ds.addFieldToSelectionList(fieldNum(LogisticsPostalAddress, CountryRegionId));
939 logisticsPostalAddressDeliveryLine_ds.addFieldToSelectionList(fieldNum(LogisticsPostalAddress, ValidFrom));
940 logisticsPostalAddressDeliveryLine_ds.addFieldToSelectionList(fieldNum(LogisticsPostalAddress, ValidTo));
941 if (#PmfEnabled)
942 {
943 bomPriceCalc.text("@PDS1468");
944 }
945 logisticsPostalAddressDeliveryLine_ds.addFieldToSelectionList(fieldNum(LogisticsPostalAddress, CountryRegionId));
946 logisticsPostalAddressShipCarrierLine_ds.addFieldToSelectionList(fieldNum(LogisticsPostalAddress, CountryRegionId));
947
948 //<GIN>
949 if (isIndiaIndirectTaxParameterMarked || isIndiaWHTMarked)
950 {
951 element.setTaxWithholdVisible_IN();
952 element.setVisible_IN();
953 }
954 // </GIN>
955
956 // <GJP>
957 element.updateDesignConsInvoice_JP();
958 // </GJP>
959
960 // <GEERU>
961 if (isRU)
962 {
963 this.initDesign_RU();
964 }
965 // </GEERU>
966
967 // <GBR>
968 salesTable_BR_ds.object(fieldNum(SalesTable_BR, cfpsId_BR)).visible(BrazilParameters::isCFPSEnabled_BR());
969 salesPurchOperationTypeController_BR = new SalesPurchOperationTypeController_BR(this.name());
970 if (BrazilParameters::isEnabled())
971 {
972 GlobalizationInstrumentationHelper::featureRun(GlobalizationConstants::FeatureReferenceBR00034, funcName());
973 }
974 // </GBR>
975
976 if (SysCountryRegionCode::isLegalEntityInCountryRegion([#isoCZ]))
977 {
978 salesTable_DS.object(fieldNum(SalesTable, StatProcId)).visible(false);
979 salesLine_DS.object(fieldNum(SalesLine, StatProcId)).visible(false);
980 }
981
982 //<GTH>
983 isUnrealizedVATEnabled = TaxThaiGovCertificationFeatureChecker::isUnrealizedVATEnabled();
984 if (isUnrealizedVATEnabled)
985 {
986 this.updateDesignForUnrealizedVAT();
987 }
988 //</GTH>
989
990 if (element.args().parmEnumType() == enumNum(FormOpenMode))
991 {
992 Object caller = element.args().caller();
993 if (caller && caller is FormRun)
994 {
995 skipLinkActive = element.args().parmEnum() == FormOpenMode::ForNew;
996 }
997 }
998
999 CustDirectDebitMandate::defaultAndDisplayMandate(
1000 salesTable.InvoiceAccount,
1001 salesTable.PaymMode,
1002 salesTable.DirectDebitMandate,
1003 false,
1004 salesTable_ds,
1005 fieldNum(SalesTable, DirectDebitMandate));
1006
1007 this.initDesignEntryCertificate_W();
1008
1009 reverseCharge = ReverseCharge_W::newParameters(salesTable, salesLine);
1010
1011 if (TaxSolutionScopeIntegrationUtil::isCompanyEnabled())
1012 {
1013 TaxDocumentLauncher.visible(true);
1014 TaxTransSource.visible(false);
1015 LineSalesTax.visible(false);
1016 LineTaxTransSource.visible(false);
1017 //TaxGroup.visible(false);
1018 }
1019
1020 if (TaxIntegrationUtils::isTaxInformationEnabled())
1021 {
1022 TransTaxInformation.visible(true);
1023 }
1024 }
1025
1026 /// <summary>
1027 /// Resets the local cache of margins
1028 /// </summary>
1029 private void resetMarginMap()
1030 {
1031 marginMap = new Map(Types::String, Types::Container);
1032 }
1033
1034 #define.2(2)
1035 void initDesign_RU()
1036 {
1037 salesLine_DS.object(fieldNum(SalesLine, ProjId)).allowEdit(true);
1038 tabHeaderAddress.columns(#2);
1039 }
1040
1041 /// <summary>
1042 /// This method shows or hides fields in the <c>Entry certificate</c> group depending on the system settings.
1043 /// </summary>
1044 private void initDesignEntryCertificate_W()
1045 {
1046 salesTable_W_ds.object(fieldNum(SalesTable_W, EntryCertificateRequired_W)).visible(custParameters.EntryCertificateManagementEnabled_W);
1047 salesTable_W_ds.object(fieldNum(SalesTable_W, IssueOwnEntryCertificate_W)).visible(custParameters.EntryCertificateIssuingEnabled_W);
1048 }
1049
1050 RecId interCompanyIsPriceDiscSearchNeeded()
1051 {
1052 return interCompanyIsPriceDiscSearchNeeded;
1053 }
1054
1055 Object inventDimSetupObject()
1056 {
1057 return inventDimFormSetup;
1058 }
1059
1060 void mcrAppendScriptStr(str _scriptStr)
1061 {
1062 /// Add the script onto the beginning of the current text in the script windows.
1063 sourceCodeScripts = _scriptStr + sourceCodeScripts;
1064 element.mcrSetScriptStr(sourceCodeScripts);
1065 }
1066
1067 /// <summary>
1068 /// Validates if the order can be completed.
1069 /// </summary>
1070 /// <returns>
1071 /// true if the order meets all completion criteria; otherwise, false.
1072 /// </returns>
1073 /// <remarks>
1074 /// An order can not be completed if no sales lines exist or if
1075 /// there is a total discount and the order is a continuity order.
1076 /// </remarks>
1077 boolean mcrCheckComplete()
1078 {
1079 // One or more sales lines must exist.
1080 if (!SalesLine::exist(salesTable.SalesId))
1081 {
1082 info("@MCR23354");
1083 warning("@MCR10878");
1084 return false;
1085 }
1086
1087 // Throw error when the order has a continuity item on it and there is
1088 // a total discount.
1089 if (mcrSalesTable.ContinuityOrder == true
1090 && salesTable.DiscPercent)
1091 {
1092 info("@MCR23354");
1093 throw error("@MCR12950");
1094 }
1095
1096 return true;
1097 }
1098
1099 /// <summary>
1100 /// Determines if the current order has
1101 /// been processed.
1102 /// </summary>
1103 /// <returns>
1104 /// true if it has; otherwise, false.
1105 /// </returns>
1106 /// <remarks>
1107 /// Criteria that stops a user from being able to switch records or close:
1108 /// 1. Parameter enabledOrderCompletion is marked.
1109 /// 2. Order is in a backOrder status.
1110 /// 3. Order is stopped.
1111 /// 4. Order is not on hold.
1112 /// 3. Order payments either do not exist or have not been processed.
1113 /// </remarks>
1114 public boolean mcrCheckOpenOrder()
1115 {
1116 if (enableOrderCompletion)
1117 {
1118 // if the status of the order being evaluated has had
1119 // its status changed to something other than open order
1120 // (backorder) clear out the buffer which indicates an open order.
1121 element.mcrClearOpenOrderSalesTableBuffer();
1122
1123 // if enable order completion is on and
1124 // if the focus is on an open order that the user just created and
1125 //the user chooses to add a new record, stop them and make the user change
1126 //the previous orders status
1127 if (openOrderSalesTable || element.isOrderCompletionRequired() || showSummaryDialog)
1128 {
1129 element.mcrPromptOpenOrderNotAllowed();
1130 if (openOrderSalesTable)
1131 {
1132 return false;
1133 }
1134 }
1135 }
1136
1137 return true;
1138 }
1139
1140 public void mcrClearOpenOrderSalesTableBuffer()
1141 {
1142 // if the status of the order being evaluated has had
1143 // its status changed to something other than open order
1144 // (backorder) clear out the buffer which indicates an open order.
1145 // Since we now allow deletes, make sure we are still on the original
1146 // sales order. If not, clear the buffer.
1147 if (salesTable.RecId == openOrderSalesTable.RecId)
1148 {
1149 if (salesTable.mcrOrderProcessed())
1150 {
1151 openOrderSalesTable = null;
1152 }
1153 }
1154 else
1155 {
1156 openOrderSalesTable = null;
1157 }
1158 }
1159
1160 void mcrClearScreen()
1161 {
1162 salesTable_ds.reread();
1163
1164 if (salesTable
1165 && salesTable.SalesStatus == SalesStatus::Backorder
1166 && enableOrderCompletion)
1167 {
1168 //do not clear
1169 return;
1170 }
1171 // clear salestable and line & set combo boxes to default(0).
1172 this.salesTable().clear();
1173 salesTable_SalesType.selection(enum2int(SalesType::Sales));
1174 salesline.clear();
1175 salestable_ds.refresh();
1176 salesline_ds.refresh();
1177
1178 mcrLastSourceId = "";
1179
1180 // clear messages
1181 if (enableDirectedSelling)
1182 {
1183 this.mcrDisplayStartOrderMessage();
1184 }
1185 }
1186
1187 void mcrCloseDownOrderEntry()
1188 {
1189 FormDataSource formDataSource;
1190
1191 // Close down order entry screen based on how the form was called.
1192 if (mcrCustomerServiceParm != MCRCustomerServiceParam::Create
1193 && mcrCustomerServiceParm != MCRCustomerServiceParam::CreateNew
1194 && mcrCustomerServiceParm != MCRCustomerServiceParam::Add
1195 && mcrCustomerServiceParm != MCRCustomerServiceParam::Modify)
1196 {
1197 salesTable_ds.executeQuery();
1198 }
1199 else
1200 {
1201 //coming from the "Create sales order" menu
1202 if (mcrCustomerServiceParm == MCRCustomerServiceParam::Add)
1203 {
1204 element.mcrClearScreen();
1205 }
1206 // coming from customer service or customer maintenance.
1207 else
1208 {
1209 // If called from customer service, refresh the sales table datasource (#2)
1210 if (element.args().caller()
1211 && element.args().caller().name() == formStr(MCRCustomerService))
1212 {
1213 formDataSource = element.args().caller().datasource(2);
1214 formDataSource.executeQuery();
1215 }
1216
1217 element.close();
1218 }
1219 }
1220 }
1221
1222 public void mcrDisableForm()
1223 {
1224 // disable sales Table
1225 salesTable_ds.allowEdit(false);
1226 salesTable_ds.allowCreate(false);
1227 salesTable_ds.allowDelete(false);
1228 salesLine_ds.allowEdit(false);
1229 salesLine_ds.allowCreate(false);
1230 salesLine_ds.allowDelete(false);
1231 }
1232
1233 void mcrDisplayCustomerMessage()
1234 {
1235 MCRScriptNote fullMessageString;
1236
1237 if (enableDirectedSelling
1238 && salesTable.CustAccount)
1239 {
1240 fullMessageString = MCRMessageAssociation::getCustomerMessage(salesTable.CustAccount);
1241 element.mcrSetScriptStr(fullMessageString);
1242 }
1243 }
1244
1245 void mcrDisplayItemMessage()
1246 {
1247 MCRScriptNote fullMessageString;
1248
1249 // Check for existence of an itemId first.
1250 if (enableDirectedSelling
1251 && salesLine.ItemId)
1252 {
1253 fullMessageString = MCRMessageAssociation::getItemMessage(salesline.ItemId,
1254 mcrSalesLine.SourceId,
1255 mcrSalesLine.UpSellOrigin,
1256 mcrSalesLine.UpSellOriginRef);
1257
1258 element.mcrSetScriptStr(fullMessageString);
1259 }
1260 }
1261
1262 void mcrDisplaySourceMessage()
1263 {
1264 MCRScriptNote fullMessageString;
1265
1266 if (enableDirectedSelling
1267 && mcrSalesTable.SourceId)
1268 {
1269 fullMessageString = MCRMessageAssociation::getSourceMessage(mcrSalesTable.SourceId);
1270
1271 element.mcrSetScriptStr(fullMessageString);
1272 }
1273 }
1274
1275 void mcrDisplayStartOrderMessage(boolean _create = false)
1276 {
1277 MCRScriptNote fullMessageString;
1278
1279 if (enableDirectedSelling)
1280 {
1281 fullMessageString = MCRMessageAssociation::getStartOrderMessage(salesTable.CustAccount,
1282 mcrSalesTable.SourceId,
1283 _create);
1284 element.mcrSetScriptStr(fullMessageString);
1285 }
1286 }
1287
1288 void mcrDisplayUpSellItemMessage()
1289 {
1290 MCRScriptNote fullMessageString;
1291
1292 // Check for existence of an itemId first.
1293 if (enableDirectedSelling
1294 && salesLine.ItemId)
1295 {
1296 fullMessageString =
1297 MCRMessageAssociation::getUpSellItemMessage(salesLine.ItemId, mcrSalesLine.UpSellOriginRef);
1298
1299 element.mcrSetScriptStr(fullMessageString);
1300 }
1301 }
1302
1303 void mcrEnableForm()
1304 {
1305 // enable sales Table
1306 salesTable_ds.allowEdit(true);
1307 salesTable_ds.allowCreate(true);
1308 salesTable_ds.allowDelete(true);
1309 //enable sales Line
1310 salesLine_ds.allowEdit(true);
1311 salesLine_ds.allowCreate(true);
1312 salesLine_ds.allowDelete(true);
1313 }
1314
1315 public MCRNotes mcrGetScript()
1316 {
1317 if (enableDirectedSelling)
1318 {
1319 return mcrScript;
1320 }
1321
1322 return '';
1323 }
1324
1325 void mcrHeaderPriceOverride(boolean _releaseOverride,
1326 RetailInformationSubcodeId _mcrReasonCode,
1327 UserId _userId)
1328 {
1329 if (#MCRPriceOverrideEnabled)
1330 {
1331 if (_releaseOverride)
1332 {
1333 mcrSalesTable.PriceOverride = NoYes::No;
1334 //The mcrSalesTable.PriceOverride value is going to be needed
1335 //within salesTable.updateFinalDisc() which gets called below.
1336 mcrSalesTable.write();
1337
1338 mcrHeaderPriceOverrideEventType = MCROrderEventType::SalesTablePriceOverrideTurnedOff;
1339 mcrHeaderPriceOverrideReasonCode = _mcrReasonCode;
1340 mcrHeaderPriceOverrideUserId = _userId;
1341 mcrHeaderPriceOverrideDiscPct = salesTable.orig().DiscPercent;
1342 // Record that a user overrode the total discount percent.
1343 salesTable.updateFinalDisc();
1344
1345 if (mcrHeaderPriceOverrideDiscPct != salesTable.DiscPercent)
1346 {
1347 element.mcrInsertPriceOverrideOrderEvent();
1348 }
1349 }
1350 else
1351 {
1352 mcrSalesTable.PriceOverride = NoYes::Yes;
1353 mcrHeaderPriceOverrideEventType = MCROrderEventType::SalesTablePriceOverrideTurnedOn;
1354 mcrHeaderPriceOverrideReasonCode = _mcrReasonCode;
1355 mcrHeaderPriceOverrideUserId = _userId;
1356 }
1357 }
1358 }
1359
1360 public void mcrInsertPriceOverrideOrderEvent()
1361 {
1362 MCROrderEventTable mcrOrderEventTable;
1363
1364 if (#MCRPriceOverrideEnabled)
1365 {
1366 ttsbegin;
1367 mcrOrderEventTable.insertFromSalesTablePriceOverride(
1368 salesTable,
1369 mcrHeaderPriceOverrideEventType,
1370 mcrHeaderPriceOverrideReasonCode,
1371 mcrHeaderPriceOverrideUserId,
1372 mcrHeaderPriceOverrideDiscPct);
1373 ttscommit;
1374 }
1375 }
1376
1377 /// <summary>
1378 /// Opens summary screen contain both return and exchange.
1379 /// </summary>
1380 void mcrLaunchOrderSummaryForReturnExchange()
1381 {
1382 FormRun formRun;
1383 Args formArgs;
1384 SalesTable salesTableReturn;
1385 SalesTableType_ReturnItem salesTableType_ReturnItem;
1386
1387 if (mcrCallCenterEnabled)
1388 {
1389 salesTableReturn = SalesTable::mcrFindReturnByExchId(salesTable.SalesId, true);
1390 salesTableType_ReturnItem = new SalesTableType_ReturnItem(salesTableReturn);
1391
1392 // Call the Return Recap form for the user to submit the return.
1393 formArgs = new Args(formstr(MCRReturnRecap));
1394 formArgs.caller(this);
1395 formArgs.record(salesTableReturn);
1396 formRun = classFactory.formRunClass(formArgs);
1397 try
1398 {
1399 if (salesTableType_ReturnItem.mcrValidateComplete())
1400 {
1401 formRun.init();
1402 formRun.run();
1403 formRun.wait();
1404 }
1405 }
1406 catch
1407 {
1408 ExceptionTextFallThrough();
1409 }
1410 }
1411 }
1412
1413 /// <summary>
1414 /// Opens summary screen and the refreshing or closing of the sales order
1415 /// is called on the complete button for order entry, and if the order returned to a status of
1416 /// open order after being cancelled.
1417 /// </summary>
1418 void mcrLaunchOrderSummary()
1419 {
1420 Args recapArgs;
1421 NoYes modifyOrder;
1422 MCROrderRecapStatus mcrOrderRecapStatus;
1423
1424 SalesTableForm::mcrCompleteMarkupTransCalc(salesTable);
1425
1426 // Open the recap form based on order completion setting, except for projects
1427 // for which the recap form is never opened.
1428 if (enableOrderCompletion
1429 && !salesTable.ProjId)
1430 {
1431 // Show the recap form.
1432 recapArgs = SalesTableForm::mcrShowOrderRecap(salesTable);
1433
1434 // Return the enum which determines if they want to continue to modify the order.
1435 // See Forms\MCRSalesOrderRecap.canClose to see where the enum is set to Yes,
1436 // if the form is closed without using 'x' or 'esc'.
1437 modifyOrder = recapArgs.parmEnum();
1438 }
1439 else
1440 {
1441 // When skipping recap, they do not need to modify order.
1442 modifyOrder = NoYes::No;
1443
1444 // Process the completion of the order like the recap form.
1445 mcrOrderRecapStatus = MCREndOrder::orderRecap(salesTable);
1446 }
1447
1448 // If the user presses modify order, then return to order.
1449 if (modifyOrder == NoYes::Yes)
1450 {
1451 element.doRefresh();
1452 }
1453 else
1454 {
1455 // The "Add" value is for when the user comes from the create sales order menu.
1456 if (mcrCustomerServiceParm == MCRCustomerServiceParam::Add)
1457 {
1458 element.mcrClearScreen();
1459 }
1460 else
1461 {
1462 // Internally marks the sales order as closed, and closes the window
1463 // if the form has been called with parameters.
1464 if (salesTable.SalesStatus != SalesStatus::Backorder
1465 || salesTable.mcrOrderStopped == NoYes::No )
1466 {
1467 openOrderSalesTable = null;
1468 }
1469
1470 // if formMode has a value, then the SalesTable form was
1471 // called from Customer Service.
1472 if (mcrCustomerServiceParm != MCRCustomerServiceParam::None)
1473 {
1474 this.mcrCloseDownOrderEntry();
1475 }
1476
1477 element.doRefresh();
1478
1479 if (!salesTable)
1480 {
1481 salesTable_ds.executeQuery();
1482 }
1483 }
1484 }
1485 }
1486
1487 /// <summary>
1488 /// Recalculates price discounts, total line amounts and creates a price override turned off order event.
1489 /// </summary>
1490 /// <param name="_userId">
1491 /// The user who overrode the price.
1492 /// </param>
1493 void mcrLinePriceOverrideNo(UserId _userId)
1494 {
1495 if (#MCRPriceOverrideEnabled)
1496 {
1497 if (salesLine.PriceDiscResultFields::canLineAmountBeUpdated())
1498 {
1499 mcrSalesLinePriceOverride.PriceOverride = NoYes::No;
1500 mcrSalesLinePriceOverride.ListPrice = 0;
1501 mcrSalesLinePriceOverride.ListPriceCurrencyCode = "";
1502 mcrSalesLinePriceOverride.ReasonCode = "";
1503 salesLine.setPriceDisc(salesLine.inventDim());
1504 //Load these values so that the appropriate values go into the order event.
1505 mcrLinePriceOverrideEventType = MCROrderEventType::SalesLinePriceOverrideTurnedOff;
1506 mcrLinePriceOverrideReasonCode = "";
1507 mcrLinePriceOverrideUserId = _userId;
1508 }
1509 else
1510 {
1511 mcrSalesLinePriceOverride.PriceOverride = NoYes::Yes;
1512 }
1513 }
1514 }
1515
1516 void mcrLinePriceOverrideYes(RetailInformationSubcodeId _reasonCode, UserId _userId = curUserId())
1517 {
1518 if (#MCRPriceOverrideEnabled)
1519 {
1520 mcrSalesLinePriceOverride.PriceOverride = NoYes::Yes;
1521 mcrSalesLinePriceOverride.ReasonCode = _reasonCode;
1522 // Load these values so that the appropriate values go into the order event.
1523 mcrLinePriceOverrideEventType = MCROrderEventType::SalesLinePriceOverrideTurnedOn;
1524 mcrLinePriceOverrideReasonCode = _reasonCode;
1525 mcrLinePriceOverrideUserId = _userId;
1526 }
1527 }
1528
1529 void mcrModify()
1530 {
1531 // Attempt to allow order to be modified.
1532 if (salesTable.mcrAllowStatusRollback())
1533 {
1534 // roll back the sales order status
1535 salesTable.mcrOpenSalesOrder();
1536
1537 if (salesTable.SalesStatus == SalesStatus::Backorder
1538 && enableOrderCompletion)
1539 {
1540 openOrderSalesTable = salesTable.data();
1541 }
1542
1543 // The active method does a lot of enabling and
1544 // disabling as well as calls set header control.
1545 // By calling active the screen should be in the correct
1546 // view for modifications.
1547 salesTable_ds.active();
1548 element.mcrSetLineControls();
1549
1550 element.doRefresh();
1551 }
1552 }
1553
1554 void mcrOrderEntryModeInit()
1555 {
1556 if (!mcrParmsSet)
1557 {
1558 retailMCRChannelTable = RetailMCRChannelTable::findChannelBySalesTable(salesTable);
1559 enableDirectedSelling = retailMCRChannelTable.mcrEnableDirectedSelling;
1560 enableOrderPriceControl = retailMCRChannelTable.mcrEnableOrderPriceControl;
1561 enableOrderCompletion = retailMCRChannelTable.mcrEnableOrderCompletion;
1562 mcrParmsSet = true;
1563 }
1564
1565 // Initialization specifically for Journals and campaigns
1566 if (element.args().parmEnumType() == enumNum(SalesTableFormId)
1567 && element.args().parmEnum() == SalesTableFormId::MCRCampaign)
1568 {
1569 salesTable_ContactPersonId.visible(true);
1570 }
1571 // Initialization specifically for telemarketing SO
1572 else if (element.args().parmEnumType() == enumNum(SalesTableFormId)
1573 && element.args().parmEnum() == SalesTableFormId::MCRTelemarketing)
1574 {
1575 mcrSalesTable_SmmTMCallListID.visible(true);
1576 salesTable_ContactPersonId.visible(true);
1577 }
1578
1579 //Parameter to see if we are called from CustomerService. (also used from custtable, salestablelistpage, MCRReturnRecap)
1580 if (element.args().parmObject()
1581 && classIdGet(element.args().parmObject()) == classIdGet(salesTableConfigure))
1582 {
1583 salesTableConfigure = element.args().parmObject();
1584 mcrCustomerServiceParm = salesTableConfigure.parmCustomerServiceParam();
1585 }
1586
1587 // Used to signify form is called by Returns
1588 if (TradeFormHelper::isCalledFromForm(element.args(), formStr(ReturnTable))
1589 || TradeFormHelper::isCalledFromForm(element.args(), formStr(MCRReturnRecap)))
1590 {
1591 returnProcessing = true;
1592 }
1593
1594 // Hide and show controls based on order parameters
1595 // Action Pane: Sales Order
1596 this.design().viewEditMode(ViewEditMode::Auto);
1597 modify.enabled(enableOrderCompletion);
1598 complete.enabled(enableOrderCompletion);
1599 creditCard.enabled(!enableOrderCompletion);
1600 payment_M_editCreditCard.enabled(!enableOrderCompletion);
1601 payment_M_editCreditCard.skip(enableOrderCompletion);
1602
1603 MCRCustomerGroup.visible(enableOrderCompletion);
1604 CopyOfDirPartyPostalAddressNewHeader.visible(!enableOrderCompletion);
1605 MCRLogisticsLocationSelectHeader1.visible(enableOrderCompletion);
1606 MCRReferences_SourceIDHeader.visible(enableOrderCompletion);
1607 LineViewWHSHeader.visible(!enableOrderCompletion);
1608 LineViewTMSHeader.visible(!enableOrderCompletion);
1609 MCRDeliveryDetails.visible(enableOrderCompletion);
1610
1611 mcrPriceOverrideIcon.enabled(enableOrderPriceControl);
1612 mcrPriceOverrideIcon.skip(!enableOrderPriceControl);
1613 mcrPriceMatch.enabled(enableOrderPriceControl);
1614 mcrSalesLinePriceOverride_PriceOverride.enabled(enableOrderPriceControl);
1615 mcrSalesLinePriceOverride_PriceOverride.skip(!enableOrderPriceControl);
1616
1617 mcrSalesTable_PriceOverride.enabled(enableOrderPriceControl);
1618 mcrSalesTable_PriceOverride.skip(!enableOrderPriceControl);
1619
1620 mcrMarginAlert.enabled(enableOrderPriceControl);
1621 mcrPriceOverride.enabled(enableOrderPriceControl);
1622 mcrPriceGroup.enabled(enableOrderPriceControl);
1623
1624 mcrCatalog.enabled(enableDirectedSelling);
1625 mcrSalesLine_LineType.enabled(enableDirectedSelling);
1626 mcrSalesLine_LineType.skip(!enableDirectedSelling);
1627 mcrSalesLine_SourceId.enabled(enableDirectedSelling);
1628 mcrItemDisplay.enabled(enableDirectedSelling);
1629 mcrSalesTable_SourceId.enabled(enableDirectedSelling);
1630 mcrSalesTable_SourceId.skip(!enableDirectedSelling);
1631 mcrDetails.enabled(enableDirectedSelling);
1632 mcrSalesTable_SourceIdGrid.enabled(enableDirectedSelling);
1633 mcrSalesTable_SourceIdGrid.skip(!enableDirectedSelling);
1634 mcrCustomerService.enabled(enableDirectedSelling);
1635
1636 if (enableOrderCompletion)
1637 {
1638 element.mcrSwapCompleteAndModifyButtons();
1639 }
1640
1641 boolean isSourceCodeRequired = mcrCallCenterOrder && mcrOrderParameters.mcrSourceCodeRequired;
1642 mcrSalesTable_ds.object(fieldNum(MCRSalesTable,SourceId)).mandatory(isSourceCodeRequired);
1643 mcrSalesLine_ds.object(fieldNum(MCRSalesLine,SourceId)).mandatory(isSourceCodeRequired);
1644 // set boolean so initial order messages are to display
1645 mcrSkipscript = 0;
1646 }
1647
1648 /// <summary>
1649 /// Completes the order like the order recap form would.
1650 /// </summary>
1651 /// <returns>
1652 /// true if the order is completed without an error; otherwise, false.
1653 /// </returns>
1654 /// <remarks>
1655 /// If an error occurs, the user is returned to modify the order.
1656 /// </remarks>
1657 [SysObsolete("The method is redundant", true)]
1658 boolean mcrProcessOrderRecap()
1659 {
1660 //Order types other than sales and returns require no processing.
1661 if (salesTable.SalesType != SalesType::Sales
1662 && salesTable.SalesType != SalesType::ReturnItem)
1663 {
1664 return true;
1665 }
1666 return true;
1667 }
1668
1669 public void mcrPromptForGiftCardUpdate()
1670 {
1671 Args credArgs;
1672 FormRun credFormRun;
1673 MCRSalesLine mcrSalesLineLocal;
1674
1675 credArgs = new Args();
1676
1677 credArgs.name(formStr(MCRGiftCardUpdatePromptDialog));
1678 credArgs.record(mcrSalesLine);
1679 credFormRun = classfactory.formRunClass(credArgs);
1680 credFormRun.run();
1681 credFormRun.wait();
1682
1683 if (credFormRun.closedOk())
1684 {
1685 mcrSalesLineLocal = credArgs.record();
1686
1687 //update fields
1688 mcrSalesLine.GiftCardNumber = mcrSalesLineLocal.GiftCardNumber;
1689 mcrSalesLine.GiftCardType = mcrSalesLineLocal.GiftCardType;
1690 mcrSalesLine.GiftCardBuyerName = mcrSalesLineLocal.GiftCardBuyerName;
1691 mcrSalesLine.GiftCardRecipientName = mcrSalesLineLocal.GiftCardRecipientName;
1692 mcrSalesLine.GiftCardBuyerEmail = mcrSalesLineLocal.GiftCardBuyerEmail;
1693 mcrSalesLine.GiftCardRecipientEmail = mcrSalesLineLocal.GiftCardRecipientEmail;
1694 mcrSalesLine.GiftCardGiftMessage = mcrSalesLineLocal.GiftCardGiftMessage;
1695
1696 mcrSalesLine_ds.refresh();
1697 }
1698 }
1699
1700 void mcrPromptOpenOrderNotAllowed()
1701 {
1702 // if the status of the order being evaluated has had
1703 // its status changed to something other than open order
1704 // (backorder) clear out the buffer which indicates an open order.
1705 // The user should not be allowed to leave an order open only if the order is
1706 // a sales order
1707 if ((showSummaryDialog || !salesTable.mcrOrderProcessed()) && element.isOrderCompletionRequired())
1708 {
1709 if (salesTable.Touched == NoYes::Yes)
1710 {
1711 salesTable.reread();
1712 }
1713
1714 if (element.mcrCheckComplete())
1715 {
1716 // Returns processing will handle completion of a return and exchange order,
1717 // therefore, don't launch the sales recap form.
1718 if (returnProcessing)
1719 {
1720 SalesTableForm::mcrCompleteMarkupTransCalc(salesTable);
1721
1722 // Need to know the user clicked complete.
1723 element.close();
1724 }
1725 else
1726 {
1727 element.mcrLaunchOrderSummary();
1728
1729 salesTable_ds.reread();
1730 salesTable_ds.refresh();
1731 salesTable_ds.active();
1732 }
1733 }
1734
1735 element.mcrClearOpenOrderSalesTableBuffer();
1736 }
1737 }
1738
1739 /// <summary>
1740 /// Refreshes the estimated margin percentage and margin icon if the margin alert
1741 /// is enabled.
1742 /// </summary>
1743 void mcrRefreshMarginAlert()
1744 {
1745 if (salesParameters.mcrEnableMarginAlert)
1746 {
1747 salesLine.setMcrMarginPercent();
1748 marginMap.remove(salesLine.InventTransId);
1749 }
1750 }
1751
1752 void mcrSetEditGiftCard()
1753 {
1754 SalesTableInteractionHelper salesTableInteractionHelper = SalesTableInteractionHelper::construct();
1755
1756 // Hide or show fields based on the item being a physical gift card
1757 salesTableInteractionHelper.mcrInitGiftCardControls(salesLine.ItemId, mcrSalesLine.GiftCardType);
1758
1759 if (salesTableInteractionHelper.parmMCRClearGiftCardNumber())
1760 {
1761 mcrSalesLine.GiftCardNumber = '';
1762 }
1763
1764 mcrUpdateGiftCard.enabled(salesTableInteractionHelper.parmMCRUpdateGiftCardEnabled());
1765 giftCardVirtual.visible(salesTableInteractionHelper.parmMCRGiftCardVirtualVisible());
1766 giftCardPhysical.visible(salesTableInteractionHelper.parmMCRGiftCardPhysicalVisible());
1767 mcrSalesLine_GiftCardNumber.visible(salesTableInteractionHelper.parmMCRGiftCardNumberVisible());
1768
1769 mcrGiftCardPolicies.visible(salesTableInteractionHelper.parmMCRGiftCardPoliciesVisible());
1770 // <GEERU>
1771 MCRSalesLine_GiftCardAmount_RU.visible(salesTableInteractionHelper.parmMCRGiftCardAmountVisible_RU());
1772 // </GEERU>
1773 }
1774
1775 void mcrSetEditItemAllowed(boolean _allowEdit)
1776 {
1777 salesLine_ds.object(fieldNum(SalesLine, ItemId)).allowEdit (_allowEdit);
1778 }
1779
1780 public void mcrSetHeaderControls()
1781 {
1782 boolean allowEdit = true;
1783 boolean allowDelete = true;
1784 SalesTableInteractionHelper salesTableInteractionHelper;
1785
1786 if (enableDirectedSelling || enableOrderCompletion)
1787 {
1788 salesTableInteractionHelper = element.createInteractionHelperAndInitHeaderControls();
1789 }
1790
1791 if (enableDirectedSelling)
1792 {
1793 //ButtonHeaderFunction
1794 salesCopyAllHeader.enabled(salesTableInteractionHelper.parmMCRHeaderFunctionButtonsEnabled());
1795 salesCopyJournalHeader.enabled(salesTableInteractionHelper.parmMCRHeaderFunctionButtonsEnabled());
1796 salesCreditNoteHeader.enabled(salesTableInteractionHelper.parmMCRHeaderFunctionButtonsEnabled());
1797 }
1798
1799 if (salesTable.isRetailCashAndCarrySales())
1800 {
1801 CancelOrderButton.enabled(false);
1802 }
1803
1804 if (enableOrderCompletion)
1805 {
1806 allowEdit = salesTableInteractionHelper.parmMCRHeaderAllowEdit();
1807 allowDelete = salesTableInteractionHelper.parmMCRHeaderAllowDelete();
1808
1809 //ButtonHeaderSetup
1810 buttonMarkupTransHeading.enabled(allowEdit);
1811
1812 //ButtonLineSetup
1813 buttonMarkupTransLine.enabled(allowEdit);
1814 lineTaxTransSource.enabled(allowEdit);
1815
1816 // Toggle the complete/modify button
1817 // Initialize buttons to not be visible. They are turned on later.
1818 element.mcrVisibleControl(complete, false); // performance tuning
1819 element.mcrVisibleControl(modify, false); // performance tuning
1820 showSummaryDialog = false;
1821
1822 // If status is Open, enable the complete button.
1823 if (salesTableInteractionHelper.parmMCRCompleteButtonEnabled())
1824 {
1825 element.mcrVisibleControl(complete, true); // performance tuning
1826 complete.enabled(true);
1827 showSummaryDialog = true;
1828 }
1829 //Otherwise, show modify.
1830 else
1831 {
1832 element.mcrVisibleControl(modify, true); // performance tuning
1833 modify.enabled(salesTableInteractionHelper.parmMCROrderModifyEnabled());
1834 }
1835 }
1836
1837 element.editSales(allowEdit, allowDelete);
1838 }
1839
1840 private boolean isOrderCompletionRequired()
1841 {
1842 boolean orderCompletionRequired = false;
1843 if (enableOrderCompletion && !MCRHoldCodeTrans::findActiveOrderHolds(salesTable.SalesId))
1844 {
1845 SalesTableInteractionHelper salesTableInteractionHelper = element.createInteractionHelperAndInitHeaderControls();
1846 orderCompletionRequired = salesTableInteractionHelper.parmMCRCompleteButtonEnabled();
1847 }
1848 return orderCompletionRequired;
1849 }
1850
1851 private SalesTableInteractionHelper createInteractionHelperAndInitHeaderControls()
1852 {
1853 SalesTableInteractionHelper salesTableInteractionHelper = SalesTableInteractionHelper::construct();
1854 salesTableInteractionHelper.mcrInitHeaderControls(salesTable,
1855 enableOrderCompletion,
1856 returnProcessing,
1857 mcrReturnSalesTable.IsExchange);
1858 return salesTableInteractionHelper;
1859 }
1860
1861 /// <summary>
1862 /// Updates controls for the sales order lines.
1863 /// </summary>
1864 void mcrSetLineControls()
1865 {
1866 SalesTableInteractionHelper salesTableInteractionHelper;
1867 boolean isLinePriceOverride;
1868
1869 if (mcrCallCenterOrder)
1870 {
1871 isLinePriceOverride = #MCRPriceOverrideEnabled ? mcrSalesLinePriceOverride.PriceOverride : false;
1872 salesTableInteractionHelper = SalesTableInteractionHelper::construct();
1873 salesTableInteractionHelper.mcrInitLineControls(salesTable,
1874 salesLine,
1875 enableOrderCompletion,
1876 enableDirectedSelling,
1877 isLinePriceOverride);
1878
1879 lineStripDelete.enabled(salesTableInteractionHelper.parmMCRLineStripDeleteEnabled());
1880 mcrLineNotesLine.enabled(salesTableInteractionHelper.parmMCRLineNotesLineEnabled());
1881
1882 if (salesTableInteractionHelper.parmMCREditItemAllowed())
1883 {
1884 element.mcrSetEditItemAllowed(true);
1885 }
1886
1887 salesLine_ds.object(fieldNum(SalesLine, SalesUnit)).allowEdit(
1888 salesTableInteractionHelper.parmMCRAllowEditSalesUnit());
1889 salesLine_ds.object(fieldNum(SalesLine, SalesQty)).allowEdit(
1890 salesTableInteractionHelper.parmMCRAllowEditSalesQty());
1891 salesLine_ds.object(fieldNum(SalesLine, SalesPrice)).enabled(salesTableInteractionHelper.parmMCRAllowEditSalesPrice());
1892
1893 mcrSalesLine_ds.object(fieldNum(MCRSalesLine, SourceId)).allowEdit(
1894 salesTableInteractionHelper.parmMCRAllowEditSourceId());
1895
1896 element.mcrSetEditGiftCard();
1897 element.mcrSetFormParts();
1898 }
1899 }
1900
1901 void mcrSetFormParts()
1902 {
1903 int i;
1904 PartList partList = new PartList(this);
1905 boolean isLineView = LineViewTab.isDisplayed();
1906
1907 // Set image and script form parts to be visible only in line view and has direct sell enabled.
1908 for (i = 1; i <= partList.partCount(); i++)
1909 {
1910 FormControl formPart = partList.getPartControlById(i);
1911 if (formPart)
1912 {
1913 formPart.visible(enableDirectedSelling && isLineView);
1914 }
1915 }
1916 }
1917
1918 void mcrSetScriptStr(str _scriptStr)
1919 {
1920 if (enableDirectedSelling)
1921 {
1922 if (mcrScript != _scriptStr
1923 && mcrSkipScript == 0)
1924 {
1925 mcrScript = _scriptStr;
1926 }
1927
1928 if (mcrSkipScript > 0)
1929 {
1930 mcrSkipScript--;
1931 }
1932 }
1933 }
1934
1935 /// <summary>
1936 /// Changes visibility of a form control when the control is not auto-declared.
1937 /// </summary>
1938 /// <param name="_formControl">
1939 /// The form control that needs to be made visible or not visible.
1940 /// </param>
1941 /// <param name="_visible">
1942 /// A Boolean to indicate if a form control has to be made visible or not visible.
1943 /// </param>
1944 void mcrVisibleControl(
1945 FormControl _formControl,
1946 boolean _visible
1947 )
1948 {
1949 // Only change visibility if value is different
1950 if (_formControl.visible() != _visible)
1951 {
1952 _formControl.visible(_visible);
1953 }
1954 }
1955
1956 /// <summary>
1957 /// Changes visibility of a data object when the object is not auto-declared.
1958 /// </summary>
1959 /// <param name="_formDataObject">
1960 /// The data object from form that needs to be made visible or not visible.
1961 /// </param>
1962 /// <param name="_visible">
1963 /// A Boolean to indicate if a form data object has to be made visible or not visible.
1964 /// </param>
1965 void mcrVisibleObject(
1966 FormDataObject _formDataObject,
1967 boolean _visible
1968 )
1969 {
1970 if (_formDataObject.visible() != _visible)
1971 {
1972 _formDataObject.visible(_visible);
1973 }
1974 }
1975
1976 /// <summary>
1977 /// Calculates multi line discounts.
1978 /// </summary>
1979 public void multiLineDiscount()
1980 {
1981 element.automaticTotalDiscount();
1982
1983 if (salesTable.updateMultiLineDisc())
1984 {
1985 salesLine_ds.research(true);
1986 }
1987 }
1988
1989 SalesId newSalesId(SalesId _newSalesId = newSalesId)
1990 {
1991 newSalesId = _newSalesId;
1992 return _newSalesId;
1993 }
1994
1995 /// <summary>
1996 /// This method sets the fields <c>RefInvoiceId</c>, <c>RefInvoiceAmountCur</c> and <c>ReasonTableRef</c>
1997 /// of table <c>SalesTable</c> editable or not.
1998 /// </summary>
1999 /// <remarks>
2000 /// These fields is not editable only when the note format is <c>TaxUnrealizedSalesNoteFormat::None</c>.
2001 /// </remarks>
2002 public void noteFormatEdit()
2003 {
2004 boolean isNoneFormat;
2005
2006 isNoneFormat = (salesTableExtensionTH.NoteFormat == TaxUnrealizedSalesNoteFormat::None);
2007
2008 salesTableExtensionTH_ds.object(fieldNum(SalesTableExtensionTH, RefInvoiceId)).allowEdit(!isNoneFormat);
2009 salesTableExtensionTH_ds.object(fieldNum(SalesTableExtensionTH, RefInvoiceAmountCur)).allowEdit(!isNoneFormat);
2010 editReasonCode_TH.allowEdit(!isNoneFormat);
2011 }
2012
2013 public LogisticsLocationRecId parmPostalAddressLocation(LogisticsLocationRecId _postalAddressLocation = 0)
2014 {
2015 if (!_postalAddressLocation)
2016 {
2017 // Set location by active datasource
2018 if (element.dataSource().name() == salesLine_ds.name())
2019 {
2020 _postalAddressLocation = salesLine.deliveryLocation();
2021 }
2022 else
2023 {
2024 _postalAddressLocation = salesTable.deliveryLocation();
2025 }
2026 }
2027
2028 postalAddressLocation = _postalAddressLocation;
2029 return postalAddressLocation;
2030 }
2031
2032 void pcConfigureLine()
2033 {
2034 boolean isConstraintBasedConfigurable = PCRuntimeLibrary::isConstraintBasedConfigurable(salesLine.ItemId);
2035
2036 if (isConstraintBasedConfigurable)
2037 {
2038 PCExecuteVariantConfiguration::execute(salesLine, salesLine.ItemId, inventDim.ConfigId);
2039 }
2040
2041 // syncs sales table with db
2042 salesLine_ds.research(true);
2043
2044 if (salesTable.mcrIsCallCenter() && salesTable.SalesType != SalesType::ReturnItem)
2045 {
2046 salesLine.setPriceDisc(SalesLine.inventDim());
2047 }
2048
2049 if (isConstraintBasedConfigurable && salesLine.type(salesTable).mustConfirmDates(SalesConfirmDatesUIStrategy::construct()))
2050 {
2051 salesLine_ds.write();
2052 }
2053 }
2054
2055 /// <summary>
2056 /// Returns if the PMF security key is enabled
2057 /// </summary>
2058 /// <returns>true if enabled; otherwise false</returns>
2059 public boolean pmfIsEnabled()
2060 {
2061 return salesLine.inventTable().isFormulaAllowed();
2062 }
2063
2064 void recalculateRetailPricesDiscounts()
2065 {
2066 RetailSalesTable retailSales = salesTable.retailSalesTable();
2067
2068 RetailSalesOrderCalculator::setPricesDiscountsOnOrderOnServer(salesTable.SalesId, retailSales.TotalManualDiscountPercentage);
2069
2070 retailSalesTable_ds.reread();
2071 retailSalesTable_ds.refresh();
2072
2073 salesLine_ds.reread();
2074 salesLine_ds.refresh();
2075
2076 SalesTable.packRetailSalesTable(retailSalesTable);
2077 }
2078
2079 void refreshSalesLine_IN()
2080 {
2081 salesLine_IN_ds.reread();
2082 salesLine_IN_ds.refresh();
2083 }
2084
2085 /// <summary>
2086 /// Refresh local cache for the sales order record
2087 /// </summary>
2088 public void refreshTmsDisplayRouteCode()
2089 {
2090 salesTableForm.tmsDisplayRouteCode(salesTable, true);
2091 }
2092
2093 public void removeAgreementLink()
2094 {
2095 SalesTableForm_DlvScheduleSyncEnabled salesTableFormDlvSchedule;
2096 SalesLine origSalesLine = salesLine.orig().data();
2097 boolean doNotAsk;
2098
2099 if (salesLine.unLinkAgreementLinePrompt())
2100 {
2101 // When the user manually removes a link to an agreement line, then also prevent automatic (re)linking of agreement lines
2102 salesLine.AgreementSkipAutoLink = NoYes::Yes;
2103
2104 if (salesLine.LineDeliveryType == LineDeliveryType::OrderLineWithMultipleDeliveries)
2105 {
2106 salesTableFormDlvSchedule = salesTableForm as SalesTableForm_DlvScheduleSyncEnabled;
2107 salesTableFormDlvSchedule.parmOrderLineOrig(origSalesLine);
2108 if (salesTableFormDlvSchedule.deliveryLinesSync(salesLine, doNotAsk))
2109 {
2110 // Re-query delivery lines displayed by grid and update grid
2111 salesLine_DS.executeQuery();
2112 }
2113 }
2114 // <GEERU>
2115 salesLine_DS.research(true);
2116 // </GEERU>
2117
2118 element.enableLineAgreementActions();
2119 }
2120 }
2121
2122 boolean returnedItem()
2123 {
2124 return salesTable.SalesType == SalesType::ReturnItem;
2125 }
2126
2127 void run()
2128 {
2129 int designatedTabNo = 1;
2130 SalesTable salesTableLocal;
2131
2132 if (TradeFormHelper::isCalledFromListPage(element.args()))
2133 {
2134 designatedTabNo = 3;
2135 }
2136
2137 // Set proper TAB explicitly.
2138 lineViewTab.tab(designatedTabNo);
2139
2140 super();
2141
2142 // Code used to create a new Sales Order within SalesTable when
2143 // it is called from Customer Service. Most of this code was taken
2144 // from SalesCreateOrder.
2145 if (mcrCustomerServiceParm == MCRCustomerServiceParam::Create || mcrCustomerServiceParm == MCRCustomerServiceParam::CreateNew)
2146 {
2147 salesTableLocal = element.args().lookupRecord();
2148 if (salesTableLocal)
2149 {
2150 salesTable_ds.positionToRecord(salesTableLocal);
2151 }
2152 else
2153 {
2154 salesTable_ds.create();
2155 }
2156 }
2157
2158 if (mcrCustomerServiceParm == MCRCustomerServiceParam::OneTime)
2159 {
2160 salesTable_ds.create();
2161 }
2162
2163 //Only setfocus if on the correct form view
2164 if (mcrSalesTable_SourceId.isDisplayed())
2165 {
2166 mcrSalesTable_SourceId.setFocus();
2167 }
2168
2169 if (salesLine_ItemId.isDisplayed()) //Only setfocus if on the correct form view
2170 {
2171 salesLine_ItemId.setFocus();
2172 }
2173 }
2174
2175 protected SalesUpdate salesUpdateFromTypeOfCreditmaxCheck()
2176 {
2177 SalesUpdate qtySpec;
2178
2179 switch (CustParameters::find().CreditMaxCheck)
2180 {
2181 case TypeOfCreditmaxCheck::BalanceDelivered:
2182 qtySpec = SalesUpdate::PackingSlip;
2183 break;
2184 case TypeOfCreditmaxCheck::BalanceAll:
2185 qtySpec = SalesUpdate::All;
2186 break;
2187 case TypeOfCreditmaxCheck::Balance:
2188 case TypeOfCreditmaxCheck::None:
2189 qtySpec = SalesUpdate::DeliverNow;
2190 break;
2191 }
2192
2193 return qtySpec;
2194 }
2195
2196 /// <summary>
2197 /// Sets the item barcode related fields on the sales line, and updates the form.
2198 /// </summary>
2199 protected void setItemBarcodeFieldsOnSalesLine()
2200 {
2201 if (isConfigurationkeyEnabled(configurationKeyNum(Retail)) && itemBarcode)
2202 {
2203 salesLine.InventDimId = itemBarcode.InventDimId;
2204
2205 salesLine_ds.itemIdModified();
2206
2207 salesLine.SalesQty = itemBarcode.Qty;
2208 salesLine.SalesUnit = itemBarcode.UnitID;
2209 }
2210 else
2211 {
2212 salesLine_ds.itemIdModified();
2213 }
2214 }
2215
2216 SalesTable salesTable()
2217 {
2218 return salesTable;
2219 }
2220
2221 /// <summary>
2222 /// Updates sales order lines if prompt was confirmed by user and any
2223 /// of the header fields with impact on the
2224 /// order lines have changed.
2225 /// </summary>
2226 /// <returns>
2227 /// A Boolean value indicating whether the update occurred.
2228 /// </returns>
2229 protected boolean updateSalesLinesWithPrompt()
2230 {
2231 if (salesTable2LineUpdatePrompt)
2232 {
2233 salesTable2LineUpdatePrompt.runOperation();
2234 salesTable2LineUpdatePrompt = null;
2235
2236 return true;
2237 }
2238
2239 return false;
2240 }
2241
2242 public void setBasisDate_IN()
2243 {
2244 CustInvoiceTrans custInvoiceTransOrig;
2245 SalesLine salesLineOrig;
2246
2247 custInvoiceTransOrig = CustInvoiceTrans::findRecId(salesLineReturnDetails_IN.CustInvoiceTrans);
2248 salesLineOrig = custInvoiceTransOrig.salesLine();
2249
2250 if (salesLineReturnDetails_IN.BasisType == SalesReturnCalculationDateType_IN::InvoiceDate)
2251 {
2252 salesLineReturnDetails_IN.BasisDate = custInvoiceTransOrig.InvoiceDate;
2253 }
2254 else if (salesLineReturnDetails_IN.BasisType == SalesReturnCalculationDateType_IN::DeliveryDate)
2255 {
2256 salesLineReturnDetails_IN.BasisDate = salesLineOrig.ReceiptDateConfirmed;
2257 }
2258 salesLineReturnDetails_IN_ds.write();
2259 }
2260
2261 void setCaptionText()
2262 {
2263 element.design().caption(strFmt(
2264 "@SYS4009992", //'%1 %2 %3 %4 %5 %6 %7 %8'
2265 "@SYS9694",
2266 salesTable.SalesId,
2267 ',',
2268 "@SYS7399",
2269 salesTableForm.captionName(),
2270 ',',
2271 "@SYS5398",
2272 salesLine.itemName()
2273 ));
2274 }
2275
2276 /// <summary>
2277 /// Defaults the site and warehouse of the current sales order line if a direct delivery warehouse is defined on the item.
2278 /// </summary>
2279 /// <param name = "_isDirectDelivery">
2280 /// A Boolean indicating if the sales order line is marked as direct delivery.
2281 /// </param>
2282 public void defaultInventDimBasedOnDirectDeliveryWarehouse(boolean _isDirectDelivery)
2283 {
2284 MCRInventTable mcrInventTable = salesLine.mcrInventTable();
2285
2286 // Set the direct delivery warehouse
2287 if (mcrInventTable.DefaultDropShipmentWarehouse)
2288 {
2289 inventDim.InventLocationId = mcrInventTable.getDefaultWarehouse(_isDirectDelivery);
2290 inventDim.InventSiteId = InventLocation::find(inventDim.InventLocationId).InventSiteId;
2291 salesLine.modifyInventDim(inventDim, fieldNum(InventDim, InventLocationId));
2292
2293 salesLine.InventDimId = InventDim::findOrCreate(inventDim).InventDimId;
2294 }
2295 }
2296
2297 /// <summary>
2298 /// Enables or disables editing of the item and sales category fields.
2299 /// </summary>
2300 /// <param name="allowEdit">
2301 /// Whether to enable editing.
2302 /// </param>
2303 void setEditItemOrCategoryAllowed(boolean allowEdit)
2304 {
2305 salesLine_ds.object(fieldNum(SalesLine, ItemId)).allowEdit(allowEdit);
2306
2307 // <GBR>
2308 if (BrazilParameters::isEnabled())
2309 {
2310 salesLine_ds.object(fieldNum(SalesLine, SalesCategory)).allowEdit(false);
2311 }
2312 else
2313 {
2314 // </GBR>
2315 salesLine_ds.object(fieldNum(SalesLine, SalesCategory)).allowEdit(allowEdit);
2316 // <GBR>
2317 }
2318 // </GBR>
2319 }
2320
2321 public void setEximFieldsAccess_IN()
2322 {
2323 EximParameters_IN eximParameters;
2324 boolean isDBKEnabled;
2325 boolean isInvoice;
2326 boolean isDEPBApplicable;
2327
2328 if (salesTable.CustomsExportOrder_IN && TaxParameters::find().EximIncentiveSchemes_IN)
2329 {
2330 eximParameters = EximParameters_IN::find();
2331 isInvoice = salesLine.SalesQty > 0 ? true : false;
2332 isDBKEnabled = isInvoice && (eximSalesLine_IN.dbkCenvatStatus != EximDBKCenvatStatus_IN::None);
2333 isDEPBApplicable = isInvoice && eximSalesLine_IN.ApplyDEPB;
2334
2335 incentiveSchemeGroup_IN.visible(true);
2336
2337 eximAA_IN.visible(eximParameters.ActivateAA);
2338 eximDFIA_IN.visible(eximParameters.ActivateDFIA);
2339
2340 eximEPCG_IN.visible(eximParameters.ActivateEPCG);
2341
2342 // buttons
2343 incentiveSchemeGroup_IN.enabled(isInvoice);
2344
2345 eximAA_IN.enabled(isInvoice);
2346 eximDFIA_IN.enabled(isInvoice);
2347
2348 eximEPCG_IN.enabled(isInvoice);
2349 }
2350 else
2351 {
2352 incentiveSchemeGroup_IN.visible(false);
2353 incentiveSchemeGroup_IN.enabled(false);
2354 eximAA_IN.enabled(false);
2355 eximDFIA_IN.enabled(false);
2356
2357 eximEPCG_IN.enabled(false);
2358 }
2359 }
2360
2361 /// <summary>
2362 /// Resetting the Return Fields when the return order becomes normal sales order.
2363 /// </summary>
2364 public void setReturnDetails_IN()
2365 {
2366 salesLineReturnDetails_IN.Period = 0;
2367 salesLineReturnDetails_IN.Type = SalesReturnType_IN::None;
2368 salesLineReturnDetails_IN.BasisType = SalesReturnCalculationDateType_IN::None;
2369 salesLineReturnDetails_IN.PeriodType = SalesReturnPeriodUnit_IN::None;
2370 salesLineReturnDetails_IN_ds.write();
2371 salesLineReturnDetails_IN_ds.reread();
2372 salesLineReturnDetails_IN_ds.refresh();
2373 salesLineReturnDetails_IN_ds.object(fieldNum(SalesLineReturnDetails_IN, Type)).allowEdit(false);
2374 salesLineReturnDetails_IN_ds.object(fieldNum(SalesLineReturnDetails_IN, BasisType)).allowEdit(false);
2375 salesLineReturnDetails_IN_ds.object(fieldNum(SalesLineReturnDetails_IN, Period)).allowEdit(false);
2376 salesLineReturnDetails_IN_ds.object(fieldNum(SalesLineReturnDetails_IN, PeriodType)).allowEdit(false);
2377 }
2378
2379 void setReturnFields()
2380 {
2381 boolean allowEditOrCreate = !salesTable.returnItem();
2382
2383 salesLine_ds.allowCreate(allowEditOrCreate);
2384
2385 // Sales header enabling and disabling
2386
2387 salesAvailableDlvDatesHeader.enabled(allowEditOrCreate && salesAvailableDlvDatesHeader.enabled());
2388
2389 salesTable_ds.object(fieldNum(SalesTable, Deadline)).allowEdit(allowEditOrCreate);
2390 salesTable_ds.object(fieldNum(SalesTable, InventLocationId)).allowEdit(allowEditOrCreate );
2391 salesTable_ds.object(fieldNum(SalesTable, Reservation)).allowEdit(allowEditOrCreate);
2392
2393 delivery.allowEdit(allowEditOrCreate);
2394 miscDelivery.allowEdit(allowEditOrCreate);
2395 transport.allowEdit(allowEditOrCreate);
2396 payment.allowEdit(allowEditOrCreate);
2397 carrierInfo.allowEdit(allowEditOrCreate);
2398
2399 tmsTransportation.allowEdit(allowEditOrCreate);
2400
2401 // Salesline enabling and disabling
2402
2403 salesAvailableDlvDatesLine.enabled(allowEditOrCreate && salesAvailableDlvDatesLine.enabled());
2404
2405 // ItemId, SalesQty, Blocked, Complete, Return lot id
2406 salesLine_ds.object(fieldNum(SalesLine, ItemId)).allowEdit(allowEditOrCreate && salesLine_ds.object(fieldNum(SalesLine, ItemId)).allowEdit());
2407 salesLine_ds.object(fieldNum(SalesLine, SalesQty)).allowEdit(allowEditOrCreate);
2408 salesLine_ds.object(fieldNum(SalesLine, Blocked)).allowEdit(allowEditOrCreate);
2409 salesLine_ds.object(fieldNum(SalesLine, Complete)).allowEdit(allowEditOrCreate);
2410 salesLine_ds.object(fieldNum(SalesLine, InventTransIdReturn)).allowEdit(allowEditOrCreate);
2411
2412 // Inventory dimensions
2413 inventDim_ds.allowEdit(allowEditOrCreate);
2414
2415 salesLine_ds.object(fieldNum(SalesLine, LedgerDimension)).allowEdit(allowEditOrCreate);
2416
2417 // Quantity
2418 salesLine_ds.object(fieldNum(SalesLine, SalesDeliverNow)).allowEdit(allowEditOrCreate);
2419
2420 // Price discount
2421 salesLine_ds.object(fieldNum(SalesLine, LinePercent)).allowEdit(allowEditOrCreate);
2422 salesLine_ds.object(fieldNum(SalesLine, LineDisc)).allowEdit(allowEditOrCreate);
2423 salesLine_ds.object(fieldNum(SalesLine, MultiLnDisc)).allowEdit(allowEditOrCreate);
2424 salesLine_ds.object(fieldNum(SalesLine, MultiLnPercent)).allowEdit(allowEditOrCreate);
2425 salesLine_ds.object(fieldNum(SalesLine, PriceUnit)).allowEdit(allowEditOrCreate);
2426 salesLine_ds.object(fieldNum(SalesLine, SalesMarkup)).allowEdit(allowEditOrCreate);
2427
2428 // Carrier info
2429 salesLine_ds.object(fieldNum(SalesLine, ShipCarrierAccount)).allowEdit(allowEditOrCreate);
2430
2431 // Bar code
2432 salesLine_ds.object(fieldNum(SalesLine, BarCode)).allowEdit(allowEditOrCreate);
2433 salesLine_ds.object(fieldNum(SalesLine, BarCodeType)).allowEdit(allowEditOrCreate);
2434
2435 // Project
2436 salesLine_ds.object(fieldNum(SalesLine, ProjId)).allowEdit(allowEditOrCreate);
2437 salesLine_ds.object(fieldNum(SalesLine, ProjCategoryId)).allowEdit(allowEditOrCreate);
2438 salesLine_ds.object(fieldNum(SalesLine, ProjTransId)).allowEdit(allowEditOrCreate);
2439 salesLine_ds.object(fieldNum(SalesLine, ActivityNumber)).allowEdit(allowEditOrCreate);
2440
2441 // Packing materials
2442 salesLine_ds.object(fieldNum(SalesLine, PackingUnit)).allowEdit(allowEditOrCreate);
2443 salesLine_ds.object(fieldNum(SalesLine, PackingUnitQty)).allowEdit(allowEditOrCreate);
2444
2445 lineDelivery.allowEdit(allowEditOrCreate);
2446 miscLineDelivery.allowEdit(allowEditOrCreate);
2447 lineInventory.allowEdit(allowEditOrCreate);
2448 }
2449
2450 public void updateExternalWorkOrderStatusVisibility()
2451 {
2452 //Integration.visible(salesTableForm.hasWorkOrderIntegrationOrigin());
2453 }
2454
2455 void setReturnFields_IN()
2456 {
2457 TransTaxInformation transTaxInformationLocal;
2458
2459 if (salesTable.SalesType == SalesType::ReturnItem)
2460 {
2461 salesLineReturnDetails_IN_ds.object(fieldNum(SalesLineReturnDetails_IN, Type)).allowEdit(salesLine.SalesQty<0);
2462 salesLineReturnDetails_IN_ds.object(fieldNum(SalesLineReturnDetails_IN, BasisType)).allowEdit(salesLineReturnDetails_IN.Type != SalesReturnType_IN::None);
2463 salesLineReturnDetails_IN_ds.object(fieldNum(SalesLineReturnDetails_IN, Period)).allowEdit(salesLineReturnDetails_IN.Type != SalesReturnType_IN::None);
2464 salesLineReturnDetails_IN_ds.object(fieldNum(SalesLineReturnDetails_IN, PeriodType)).allowEdit(salesLineReturnDetails_IN.Type != SalesReturnType_IN::None);
2465
2466
2467 if (ReturnDispositionCode::find(salesLine.ReturnDispositionCodeId).DispositionAction == DispositionAction::CreditOnly)
2468 {
2469 ttsbegin;
2470 transTaxInformationLocal = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(salesLine, true);
2471
2472 transTaxInformationLocal.ExciseRecordType = ExciseRecordType_IN::None;
2473 transTaxInformationLocal.ExciseDirectSettlement = DirectSettlement_IN::None;
2474 transTaxInformationLocal.doUpdate();
2475 ttscommit;
2476 }
2477 }
2478
2479 SalesLine_IN_ReturnAction.visible(TaxParameters::isExciseEnable_IN() && salesTable.SalesType == SalesType::Sales && salesTable.ReturnItemNum);
2480 }
2481
2482 void setTaxWithholdEnabled_IN()
2483 {
2484 salesTable_ds.object(fieldNum(SalesTable, tcsGroup_IN)).enabled(!salesTable.tdsGroup_IN);
2485 salesTable_ds.object(fieldNum(SalesTable, tdsGroup_IN)).enabled(!salesTable.tcsGroup_IN);
2486 salesLine_IN_ds.object(fieldNum(SalesLine_IN, tcsGroup)).enabled(!salesLine_IN.tdsGroup);
2487 salesLine_IN_ds.object(fieldNum(SalesLine_IN, tdsGroup)).enabled(!salesLine_IN.tcsGroup);
2488 buttonWithholdTax_IN.enabled(salesLine_IN.tdsGroup || salesLine_IN.tcsGroup);
2489 if (salesLine.InventTransIdReturn)
2490 {
2491 salesTable_ds.object(fieldNum(SalesTable, tcsGroup_IN)).enabled(!salesLine.InventTransIdReturn);
2492 salesTable_ds.object(fieldNum(SalesTable, tdsGroup_IN)).enabled(!salesLine.InventTransIdReturn);
2493 salesLine_IN_ds.object(fieldNum(SalesLine_IN, tcsGroup)).enabled(!salesLine.InventTransIdReturn);
2494 salesLine_IN_ds.object(fieldNum(SalesLine_IN, tdsGroup)).enabled(!salesLine.InventTransIdReturn);
2495 }
2496 }
2497
2498 void setTaxWithholdVisible_IN()
2499 {
2500 TaxWithholdParameters_IN taxWithholdParameters;
2501
2502 taxWithholdParameters = TaxWithholdParameters_IN::find();
2503 salesTable_ds.object(fieldNum(SalesTable, tdsGroup_IN)).visible(taxWithholdParameters.tdsActivate);
2504 salesLine_IN_ds.object(fieldNum(SalesLine_IN, tdsGroup)).visible(taxWithholdParameters.tdsActivate);
2505 salesTable_ds.object(fieldNum(SalesTable, tcsGroup_IN)).visible(taxWithholdParameters.tcsActivate);
2506 salesLine_IN_ds.object(fieldNum(SalesLine_IN, tcsGroup)).visible(taxWithholdParameters.tcsActivate);
2507 //withholdingTax_IN.visible(taxWithholdParameters.tdsActivate || taxWithholdParameters.tcsActivate);
2508 lineWithholdingTax_IN.visible(taxWithholdParameters.tdsActivate || taxWithholdParameters.tcsActivate);
2509 buttonWithholdTax_IN.visible(taxWithholdParameters.tdsActivate || taxWithholdParameters.tcsActivate);
2510 }
2511
2512 private void setVisible_IN()
2513 {
2514 TaxParameters taxParametersLoc = TaxParameters::find();
2515
2516 salesLine_AssessableValue_IN.visible(isIndiaIndirectTaxParameterMarked);
2517 salesLine_MaximumRetailPrice_IN.visible(isIndiaIndirectTaxParameterMarked);
2518
2519 salesLine_CustomsMaxRetailPrice_IN.visible(salesTable.CustomsExportOrder_IN == NoYes::Yes && TaxParameters::find().Customs_IN == NoYes::Yes);
2520 salesTable_ds.object(fieldNum(SalesTable, CustomsExportOrder_IN)).visible(taxParametersLoc.Customs_IN);
2521
2522 createExportOrder_IN.visible(taxParametersLoc.Customs_IN);
2523 customerReturns_IN.visible(isIndiaIndirectTaxParameterMarked);
2524 }
2525
2526 [SysObsolete('Method is no longer used. Please use showHeaderLogisticsPostalEffectiveAddressMessage() or showLineLogisticsPostalEffectiveAddressMessage instead')]
2527 public void showInactiveAddressBar()
2528 {
2529 LogisticsLocationEntity::showHideEffectiveAddressMessageBar(element, logisticsPostalAddressDeliveryHeader, logisticsPostalAddressDeliveryLine);
2530 }
2531
2532 [Hookable(false), Wrappable(false)]
2533 internal void showHeaderLogisticsPostalEffectiveAddressMessage()
2534 {
2535 // Keep the message appearing on the order details pages (not on the list) only with status Open
2536 if (element.viewOptionHelper().getViewOption() != FormViewOption::Grid
2537 && salesTable.SalesStatus == SalesStatus::Backorder
2538 && (logisticsPostalAddressDeliveryHeader.RecId && !logisticsPostalAddressDeliveryHeader.isEffective()))
2539 {
2540 warning("@SalesAndMarketing:HeaderEffectiveAddressMessage");
2541 }
2542 }
2543
2544 [Hookable(false), Wrappable(false)]
2545 internal void showLineLogisticsPostalEffectiveAddressMessage()
2546 {
2547 // Keep the message appearing on the order details pages (not on the list) only with status Open
2548 if (element.viewOptionHelper().getViewOption() == FormViewOption::Details
2549 && (salesLine.RecId && salesLine.SalesStatus == SalesStatus::Backorder)
2550 && (logisticsPostalAddressDeliveryLine.RecId && !logisticsPostalAddressDeliveryLine.isEffective()))
2551 {
2552 warning("@SalesAndMarketing:LineEffectiveAddressMessage");
2553 }
2554 }
2555
2556 /// <summary>
2557 /// Sets all the fields that depend on carrier.
2558 /// </summary>
2559 /// <param name="_dlvModeId">
2560 /// The delivery mode Id
2561 /// </param>
2562 public void tmsSetCarrierFieldsFromDlvMode(DlvModeId _dlvModeId)
2563 {
2564 TMSCarrierService carrierService;
2565
2566 carrierService = TMSCarrierService::findByDlvModeId(_dlvModeId);
2567
2568 tmsSalesTable.CarrierCode = carrierService.CarrierCode;
2569 tmsSalesTable.CarrierServiceCode = carrierService.CarrierServiceCode;
2570 tmsSalesTable.ModeCode = TMSCarrier::find(carrierService.CarrierCode).ModeCode;
2571
2572 tmsSalesTable_ds.refresh();
2573 }
2574
2575 /// <summary>
2576 /// Updates the sales order after transportation fields are updated
2577 /// </summary>
2578 public void tmsUpdateSalesOrder()
2579 {
2580 salesTable.DlvMode = TMSCarrierService::findDlvModeId(tmsSalesTable.CarrierCode, tmsSalesTable.CarrierServiceCode);
2581
2582 salesTable_ds.refresh();
2583 }
2584
2585 void updateDesign(InventDimFormDesignUpdate mode)
2586 {
2587 InventMovement movement = InventMovement::construct(salesLine);
2588 Set validInventDimDSset;
2589 InventDimControlIdCollection inventDimControlIdCollection;
2590 boolean emptyLine;
2591
2592 switch (mode)
2593 {
2594 case InventDimFormDesignUpdate::Init:
2595 if (!inventDimFormSetup)
2596 {
2597 validInventDimDSset = new Set(Types::String);
2598 validInventDimDSset.add(inventDim_ds.name());
2599 inventDimControlIdCollection = InventDimControlIdCollection::construct();
2600 inventDimControlIdCollection.add(storageDimensions.id(), false);
2601 inventDimControlIdCollection.add(trackingDimensions.id(), false);
2602 inventDimControlIdCollection.add(productDimensions.id(), false);
2603 inventDimControlIdCollection.add(inventoryDimensionsGrid.id(), true);
2604 inventDimFormSetup = InventDimCtrl_Frm_Mov_OrderLine::newFromFormMovement(element, movement, validInventDimDSset
2605 , inventDimControlIdCollection
2606 );
2607 }
2608
2609 case InventDimFormDesignUpdate::Active,
2610 InventDimFormDesignUpdate::FieldChange:
2611 emptyLine = salesLine.ItemId == '' && salesLine.SalesCategory == 0;
2612 storageDimensions.allowEdit(!emptyLine);
2613 trackingDimensions.allowEdit(!emptyLine);
2614 productDimensions.allowEdit(!emptyLine);
2615 inventoryDimensionsGrid.allowEdit(!emptyLine);
2616 if (!emptyLine)
2617 {
2618 //For performance reasons, only call the inventDimFormSetup if the order line has an item ID or Category ID.
2619 inventDimFormSetup.formActiveSetup(movement.inventDimGroupSetup(), movement);
2620 inventDimFormSetup.formSetControls(mode == InventDimFormDesignUpdate::Active);
2621 }
2622 break;
2623
2624 default :
2625 throw error(strFmt("@SYS54195",funcName()));
2626 }
2627
2628 // <GMY>
2629 if (isIsoMY)
2630 {
2631 if (SalesTable.canInvoiceOrderFromCurrentSalesStatus())
2632 {
2633 Format_MY_M_editInvoiceType_MY.allowEdit(true);
2634 }
2635 else
2636 {
2637 Format_MY_M_editInvoiceType_MY.allowEdit(false);
2638 }
2639 }
2640 // </GMY>
2641 }
2642
2643 public void updateDesign_MX()
2644 {
2645 if (EInvoiceParameters_MX::isElectronicInvoiceEnabled() || EInvoiceCFDIParameters_MX::isElectronicInvoiceEnabled() )
2646 {
2647 eInvoice_MX.visible(true);
2648 }
2649 else
2650 {
2651 eInvoice_MX.visible(false);
2652 }
2653 }
2654
2655 /// <summary>
2656 /// Updates the design for the consolidation invoice related controls.
2657 /// </summary>
2658 void updateDesignConsInvoice_JP()
2659 {
2660 if (!CustConsInvoiceType_JP::isCustConsInvoiceEnabled())
2661 {
2662 salesTable_ds.object(fieldNum(SalesTable, ConsTarget_JP)).visible(false);
2663 consTarget_JP.visible(false);
2664 }
2665 }
2666
2667 /// <summary>
2668 /// Sets fields visible.
2669 /// </summary>
2670 private void updateDesignForUnrealizedVAT()
2671 {
2672 noteFormat_TH.visible(true);
2673 salesTable_RefInvoiceId_TH.visible(true);
2674 salesTable_RefInvoiceAmountCur_TH.visible(true);
2675 editReasonCode_TH.visible(true);
2676 salesTable_TaxAgent_TH.visible(true);
2677
2678 this.noteFormatEdit();
2679 }
2680
2681 /// <summary>
2682 /// Return order fields specific to India are getting updated here.
2683 /// </summary>
2684 public void updateReturnableDetails_IN()
2685 {
2686 SalesReturnInformation_IN salesReturnInformation;
2687 TaxInformation_IN taxInformation;
2688 SalesReturn_IN salesReturn = SalesReturn_IN::construct(salesLine.TaxItemGroup);
2689 SalesReturnPeriodUnit_IN salesReturnPeriodUnit = SalesReturnPeriodUnit_IN::None;
2690 SalesReturnCalculationDateType_IN salesReturnCalculationDateType = SalesReturnCalculationDateType_IN::None;
2691 SalesLine salesLineOrig;
2692 CustInvoiceTrans custInvoiceTransOrig;
2693 TransTaxInformation transTaxInformationLocal;
2694
2695 transTaxInformationLocal = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(salesLine);
2696
2697 taxInformation = TaxInformation_IN::find(transTaxInformationLocal.TaxInformation);
2698 salesReturnInformation = salesReturn.getReturnInformation(taxInformation);
2699
2700 if (salesLineReturnDetails_IN.Type != SalesReturnType_IN::None && salesReturnInformation.RecId)
2701 {
2702 salesLineReturnDetails_IN.BasisType = (str2enum(salesReturnCalculationDateType, enum2Value(salesReturnInformation.BasisType)));
2703
2704 if (salesLineReturnDetails_IN.Type == SalesReturnType_IN::CustomerReturns)
2705 {
2706 salesLineReturnDetails_IN.Period = salesReturnInformation.Period;
2707 salesLineReturnDetails_IN.PeriodType = (str2enum(salesReturnPeriodUnit, enum2Value(salesReturnInformation.PeriodType)));
2708 }
2709 else
2710 {
2711 salesLineReturnDetails_IN.Period = salesReturnInformation.IncompletePeriod;
2712 salesLineReturnDetails_IN.PeriodType = (str2enum(salesReturnPeriodUnit, enum2Value(salesReturnInformation.IncompletePeriodType)));
2713 }
2714 if (salesLine.InventTransIdReturn)
2715 {
2716 custInvoiceTransOrig = CustInvoiceTrans::findRecId(salesLineReturnDetails_IN.CustInvoiceTrans);
2717 salesLineOrig = custInvoiceTransOrig.salesLine();
2718 if (salesReturnInformation.BasisType == CustomerCalculationDateType_IN::InvoiceDate)
2719 {
2720 salesLineReturnDetails_IN.BasisDate = custInvoiceTransOrig.InvoiceDate;
2721 }
2722 else if (salesReturnInformation.BasisType == CustomerCalculationDateType_IN::DeliveryDate)
2723 {
2724 salesLineReturnDetails_IN.BasisDate = salesLineOrig.ReceiptDateConfirmed ;
2725 }
2726 }
2727 salesLineReturnDetails_IN.SalesLine_IN = salesLine_IN.RecId;
2728 salesLineReturnDetails_IN_ds.object(fieldNum(SalesLineReturnDetails_IN, BasisType)).allowEdit(true);
2729 salesLineReturnDetails_IN_ds.object(fieldNum(SalesLineReturnDetails_IN, Period)).allowEdit(true);
2730 salesLineReturnDetails_IN_ds.object(fieldNum(SalesLineReturnDetails_IN, PeriodType)).allowEdit(true);
2731 salesLineReturnDetails_IN_ds.write();
2732 }
2733 else
2734 {
2735 salesLineReturnDetails_IN.Period = 0;
2736 salesLineReturnDetails_IN.BasisType = SalesReturnCalculationDateType_IN::None;
2737 salesLineReturnDetails_IN.PeriodType = SalesReturnPeriodUnit_IN::None;
2738 salesLineReturnDetails_IN_ds.write();
2739 salesLineReturnDetails_IN_ds.object(fieldNum(SalesLineReturnDetails_IN, BasisType)).allowEdit(salesLineReturnDetails_IN.Type != SalesReturnType_IN::None);
2740 salesLineReturnDetails_IN_ds.object(fieldNum(SalesLineReturnDetails_IN, Period)).allowEdit(salesLineReturnDetails_IN.Type != SalesReturnType_IN::None);
2741 salesLineReturnDetails_IN_ds.object(fieldNum(SalesLineReturnDetails_IN, PeriodType)).allowEdit(salesLineReturnDetails_IN.Type != SalesReturnType_IN::None);
2742 }
2743 }
2744
2745 boolean useRetailPricingEngine()
2746 {
2747 return RetailPricingEngine::useRetailPricingEngineForSalesOrder(salesTable.SalesId);
2748 }
2749
2750 /// <summary>
2751 /// Record details of manual override.
2752 /// </summary>
2753 /// <param name="_reasonCode">
2754 /// Reason code used to change price/discount.
2755 /// </param>
2756 /// <param name="_userId">
2757 /// user id.
2758 /// </param>
2759 void mcrLineManualDiscountOverride(RetailInformationSubcodeId _reasonCode, UserId _userId = curUserId())
2760 {
2761 if (#MCRPriceOverrideEnabled)
2762 {
2763 mcrSalesLinePriceOverride.PriceOverride = NoYes::No;
2764 mcrSalesLinePriceOverride.ReasonCode = _reasonCode;
2765 // Load these values so that the appropriate values go into the order event.
2766 mcrLinePriceOverrideEventType = MCROrderEventType::SalesLinePriceOverrideTurnedOn;
2767 mcrLinePriceOverrideReasonCode = _reasonCode;
2768 mcrLinePriceOverrideUserId = _userId;
2769 }
2770 }
2771
2772 /// <summary>
2773 /// Enable/Disable the EDIT button according to current status of sales order
2774 /// </summary>
2775 public void mcrSwapCompleteAndModifyButtons()
2776 {
2777 boolean completeButtonIsEnable = (salesTable.SalesStatus == SalesStatus::Backorder && salesTable.mcrOrderStopped == NoYes::Yes);
2778
2779 this.design().viewEditMode(completeButtonIsEnable ? ViewEditMode::Auto : ViewEditMode::View);
2780
2781 LineOverviewMainActionButtonGroup.enabled(completeButtonIsEnable);
2782
2783 // Toggle edit mode of the form.
2784 // Do it only not in a transaction.
2785 if (element.inViewMode() == completeButtonIsEnable && appl.ttsLevel() ==0)
2786 {
2787 element.task(#taskEditRecord);
2788 }
2789 }
2790
2791 /// <summary>
2792 /// Performs lookup for <c>CustInvoiceJour</c> table.
2793 /// </summary>
2794 /// <param name="_control">
2795 /// The control to require lookup.
2796 /// </param>
2797 /// <param name="_queryRange">
2798 /// The range of query.
2799 /// </param>
2800 /// <param name="_custAccount">
2801 /// The account of customer.
2802 /// </param>
2803 public void performCustInvoiceJourLookup_MY(
2804 FormStringControl _control,
2805 Range _queryRange,
2806 CustAccount _custAccount)
2807 {
2808 custInvoiceJourLookupController.parmQueryRange(_queryRange);
2809 custInvoiceJourLookupController.parmCustAccount(_custAccount);
2810 custInvoiceJourLookupController.performLookup(_control);
2811 }
2812
2813 /// <summary>
2814 /// Updates the controls used for selecting source invoice transaction.
2815 /// </summary>
2816 public void updateSourceRefControlsAfterLookup_MY()
2817 {
2818 if (custInvoiceJourLookupController.parmInvoiceInfo())
2819 {
2820 [salesLine_W.RefInvoiceId_MY, salesLine_W.RefInvoiceDate_MY] = custInvoiceJourLookupController.parmInvoiceInfo();
2821
2822 // After updated, clear the InvoiceInfo container of CustInvoiceJourLookupController to prepare for next lookup.
2823 custInvoiceJourLookupController.parmInvoiceInfo(conNull());
2824 }
2825 }
2826
2827 /// <summary>
2828 /// Refresh retail related datasources
2829 /// </summary>
2830 private void refreshRetailDatasource()
2831 {
2832 if (isRetailOrder)
2833 {
2834 RetailSalesTable newRetailSalesTable = RetailSalesTable::findSalesTable(salesTable);
2835 if (newRetailSalesTable)
2836 {
2837 LoyaltyCardLineView.dataSourceObject().clearReferenceData(fieldNum(RetailSalesTable, RetailLoyaltyCard));
2838 RetailSalesTable.data(newRetailSalesTable);
2839 RetailSalesTable_ds.rereadReferenceDataSources();
2840 RetailSalesTable_ds.refresh();
2841 }
2842 }
2843
2844 // for call center orders refresh data source
2845 if (mcrCallCenterOrder)
2846 {
2847 MCRSalesTable newMCRSalesTable = MCRSalesTable::findSalesId(salesTable.SalesId);
2848 if (newMCRSalesTable)
2849 {
2850 MCRSalesTable.data(newMCRSalesTable);
2851 MCRSalesTable_ds.rereadReferenceDataSources();
2852 MCRSalesTable_ds.refresh();
2853 }
2854 }
2855 }
2856
2857 public int task(int _taskId)
2858 {
2859 #Task
2860 int ret;
2861
2862 newButtonCurrentSalesId = ((taskId == #taskNew) && (_taskId == #taskClearFfilter)) ? salesTable.SalesId : null;
2863 taskId = _taskId;
2864
2865 ret = super(_taskId);
2866 if (mcrCallCenterEnabled &&
2867 (_taskId == #taskSwitchToDetailsView || _taskId == #taskSwitchToHeaderDetailsView || _taskId == #taskSwitchToLineDetailsView))
2868 {
2869 this.mcrSetFormParts();
2870 }
2871
2872 return ret;
2873 }
2874
2875 private boolean forceCompleteReturn()
2876 {
2877 boolean ret;
2878 SalesTable salesTableReturn;
2879 SalesLine salesLineReturn;
2880
2881 if (mcrCallCenterEnabled)
2882 {
2883 // valid return order exists.
2884 select firstOnly RecId from salesTableReturn
2885 where salesTableReturn.ReturnReplacementId == salesTable.SalesId
2886 exists join salesLineReturn
2887 where salesLineReturn.SalesId == salesTableReturn.SalesId
2888 && salesLineReturn.ExpectedRetQty != 0;
2889
2890 ret = salesTableReturn ? true : false;
2891 }
2892
2893 return ret;
2894 }
2895
2896 /// <summary>
2897 /// Sets product value based on selected product from the lookup.
2898 /// </summary>
2899 public void setProductFromLookup(InventDistinctProduct _product)
2900 {
2901 productFromLookup = _product;
2902 }
2903
2904 /// <summary>
2905 /// Updates product dimensions on the sales line.
2906 /// </summary>
2907 /// <param name="_inventDim">
2908 /// An instance of <c>InventDim</c> that provides the new product dimensions.
2909 /// </param>
2910 public void updateProductDimensions(InventDim _inventDim)
2911 {
2912 Set productDimensionFields = inventDim.copyProductDimensionsAndGetModifiedDimensionFields(_inventDim, salesLine.ItemId);
2913 if (productDimensionFields)
2914 {
2915 element.modifyInventDimSet(inventDim, productDimensionFields);
2916 element.performUpdatePostProductDimensionChange();
2917 }
2918 }
2919
2920 /// <summary>
2921 /// Performs updates needed after product dimension changes.
2922 /// </summary>
2923 public void performUpdatePostProductDimensionChange()
2924 {
2925 if (salesLine.DeliveryDateControlType)
2926 {
2927 SalesCalcAvailableDlvDates salesCalcAvailableDlvDates = SalesCalcAvailableDlvDates::newCommonSalesDlvDateType(salesLine, 0, inventDim);
2928 salesCalcAvailableDlvDates.modifiedFieldBeforeInsert(salesLine);
2929 }
2930
2931 salesLine_DS.cacheCalculateMethod(tableMethodStr(SalesLine,itemName));
2932
2933 element.mcrRefreshMarginAlert();
2934
2935 element.findProductNumber();
2936 }
2937
2938 /// <summary>
2939 /// Returns the related <c>PurchTable</c> record for this <c>SalesTable</c> taking the line selection into account.
2940 /// If the <c>SalesLine</c> record does not have a referenced <c>PurchTable</c> then the referenced <c>PurchTable</c> record of the <c>SalesTable</c> is returned.
2941 /// </summary>
2942 /// <param name = "_intercompany">If the related <c>PurchTable</c> record must be part of an intercompany chain.</param>
2943 /// <returns>The related <c>PurchTable</c> record for this <c>SalesTable</c> taking the line selection into account.</returns>
2944 private PurchTable referencedPurchTableConsideringLineSelection(boolean _intercompany)
2945 {
2946 if (!_intercompany || SalesLine.isIntercompanyOrigin())
2947 {
2948 PurchLine referencedPurchLine = salesLine.referencedPurchLine();
2949 if (referencedPurchLine)
2950 {
2951 return referencedPurchLine.purchTable();
2952 }
2953 }
2954
2955 return salesTable.referencePurchTable();
2956 }
2957
2958 public void modifyInventDimField(FieldId _fieldId)
2959 {
2960 if (salesLine.modifyInventDim(inventDim, _fieldId, !salesLine.MatchingAgreementLine))
2961 {
2962 InventDim.data(SalesLine.inventDim());
2963 InventDim_DS.setCurrent();
2964 }
2965 }
2966
2967 /// <summary>
2968 /// Updates <c>InventDim</c> data based on the given set of modified dimension fields.
2969 /// </summary>
2970 /// <param name = "_inventDim">The new inventory dimension record.</param>
2971 /// <param name = "_dimFields">A set containing the ID's of the modified <c>InventDim</c> fields.</param>
2972 public void modifyInventDimSet(InventDim _inventDim, Set _dimFields)
2973 {
2974 if (salesLine.modifyInventDimSet(_inventDim, _dimFields, !salesLine.MatchingAgreementLine))
2975 {
2976 InventDim.data(salesLine.inventDim());
2977 InventDim_DS.setCurrent();
2978 }
2979 }
2980
2981 /// <summary>
2982 /// Updates source identifier on sales table header to sales lines.
2983 /// </summary>
2984 public void mcrUpdateSourceIdToSalesLines()
2985 {
2986 SalesLine salesLineLocal;
2987
2988 MCRSalesTable.update();
2989
2990 // Unable to replace by a set based update because there are extensions consuming salesLine.mcrUpdateSourceId()
2991 while select forUpdate salesLineLocal
2992 where salesLineLocal.SalesId == SalesTable.SalesId
2993 {
2994 salesLineLocal.mcrUpdateSourceId(mcrSalesTable.SourceId);
2995 }
2996
2997 element.recalculateRetailPricesDiscounts();
2998 }
2999
3000 /// <summary>
3001 /// Check if workflow action button will be displayed.
3002 /// </summary>
3003 /// <param name = "_workflowType">
3004 /// Workflow type.
3005 /// </param>
3006 /// <returns>
3007 /// Return true if any line needs to submit and not submitted.
3008 /// </returns>
3009 public boolean canSubmitToWorkflow(str _workflowType = '')
3010 {
3011 boolean ret;
3012 MCRSalesLine mcrSalesLineLocal;
3013 SalesLine salesLineLocal;
3014
3015 if (mcrSalesLine)
3016 {
3017 // if current line is not submitted or approved
3018 if (mcrSalesLine.RetailPriceOverrideWorkflowState == RetailPriceOverrideWorkflowState::NotSubmitted || mcrSalesLine.RetailPriceOverrideWorkflowState == RetailPriceOverrideWorkflowState::Approved || mcrSalesLine.RetailPriceOverrideWorkflowState == RetailPriceOverrideWorkflowState::None)
3019 {
3020 // and if any non submit line is need to submit for approval
3021 select firstonly RecId from mcrSalesLineLocal
3022 join RecId from salesLineLocal
3023 where mcrSalesLineLocal.SalesLine == salesLineLocal.RecId && salesLineLocal.SalesId == salesTable.SalesId
3024 && mcrSalesLineLocal.RetailPriceOverrideWorkflowState == RetailPriceOverrideWorkflowState::NotSubmitted;
3025
3026 if (mcrSalesLineLocal)
3027 {
3028 ret = true;
3029 }
3030
3031 }
3032 }
3033
3034 // hide workflow action button even if the line is rejected and the line's status is None and no not submitted lines
3035 element.design().controlName("WorkflowActionBarButtonGroup").visible(ret || mcrSalesLine.RetailPriceOverrideWorkflowState != RetailPriceOverrideWorkflowState::None);
3036
3037 return ret;
3038 }
3039
3040 /// <summary>
3041 /// Updates the linked datasources to the sales table datasource.
3042 /// </summary>
3043 protected void salesTableLinkActiveBasedOnDatasource()
3044 {
3045 ProjTable projTableLink;
3046 QueryBuildRange projIdSalesTable;
3047
3048 switch (element.args().dataset())
3049 {
3050 case tableNum(CostControlTransCommittedCost):
3051 CostControlTransCommittedCost costControlTransCommittedCost = element.args().record() as CostControlTransCommittedCost;
3052 queryBuildRangeSalesId.value(queryValue(costControlTransCommittedCost.RefId));
3053 break;
3054
3055 case tableNum(ProjTable) :
3056 projTableLink = element.args().record() as ProjTable;
3057 queryBuildRangeProjId.value(projTableLink.ProjId+'*');
3058 break;
3059 case tableNum(ProjInvoiceTable):
3060 projIdSalesTable = salesTable_ds.query().dataSourceTable(tableNum(SalesTable)).findRange(fieldNum(SalesTable,ProjId));
3061
3062 while (projIdSalesTable)
3063 {
3064 salesTable_ds.query().dataSourceTable(tableNum(SalesTable)).clearRange(fieldNum(SalesTable,ProjId));
3065 projIdSalesTable = salesTable_ds.query().dataSourceTable(tableNum(SalesTable)).findRange(fieldNum(SalesTable,ProjId));
3066 }
3067
3068 ProjInvoiceTable projInvoiceTableLink = element.args().record() as ProjInvoiceTable;
3069
3070 while select ProjId from projTableLink
3071 where projTableLink.ProjInvoiceProjId == projInvoiceTableLink.ProjInvoiceProjId
3072 {
3073 salesTable_ds.query().dataSourceTable(tableNum(SalesTable)).addRange(fieldNum(SalesTable,ProjId)).value(projTableLink.ProjId);
3074 }
3075 break;
3076
3077 case tableNum(ProjWIPTable) :
3078 projIdSalesTable = salesTable_ds.query().dataSourceTable(tableNum(SalesTable)).findRange(fieldNum(SalesTable,ProjId));
3079
3080 while (projIdSalesTable)
3081 {
3082 salesTable_ds.query().dataSourceTable(tableNum(SalesTable)).clearRange(fieldNum(SalesTable,ProjId));
3083 projIdSalesTable = salesTable_ds.query().dataSourceTable(tableNum(SalesTable)).findRange(fieldNum(SalesTable,ProjId));
3084 }
3085
3086 ProjWIPTable projWIPTable = element.args().record() as ProjWIPTable;
3087
3088 while select ProjId from projTableLink
3089 where projTableLink.wipProject == projWIPTable.ProjId
3090 {
3091 salesTable_ds.query().dataSourceTable(tableNum(SalesTable)).addRange(fieldNum(SalesTable,ProjId)).value(projTableLink.ProjId);
3092 }
3093
3094 break;
3095
3096 case tableNum(smmActivities) :
3097 smmActivityParentLink::updateQuery(salestable_ds.query().dataSourceTable(tableNum(SalesTable)), element.args().record() as smmActivities);
3098 break;
3099 // If deduction has salesId specified, show that sales order, otherwise
3100 // show all sales orders with invoice account equal to deduction's account
3101 case tableNum(TAMDeduction) :
3102 // Clear ranges
3103 salesTable_ds.query().dataSourceTable(tableNum(SalesTable)).
3104 clearRange(fieldNum(SalesTable, InvoiceAccount));
3105 salesTable_ds.query().dataSourceTable(tableNum(SalesTable)).
3106 clearRange(fieldNum(SalesTable, SalesId));
3107
3108 TAMDeduction tamDeduction;
3109 tamDeduction.data(element.args().record());
3110 if (tamDeduction.SalesId)
3111 {
3112 // If deduction has SalesId just show that sales order
3113 salesTable_ds.query().dataSourceTable(tableNum(SalesTable))
3114 .addRange(fieldNum(SalesTable, SalesId)).value(tamDeduction.SalesId);
3115 }
3116 else
3117 {
3118 // If no SalesId specified show all sales orders with invoice
3119 // account equal to deduction's account
3120 salesTable_ds.query().dataSourceTable(tableNum(SalesTable))
3121 .addRange(fieldNum(SalesTable, InvoiceAccount)).value(tamDeduction.AccountNum);
3122 }
3123 break;
3124 }
3125 }
3126
3127 /// <summary>
3128 /// Rereads the salesLine record from db and refreshes the margin alert cache.
3129 /// </summary>
3130 /// <remarks>
3131 /// This method will be called from an external class.
3132 /// </remarks>
3133 public void mcrRereadMarginAlert()
3134 {
3135 RecVersion versionBeforeUpdate = salesLine.RecVersion;
3136 salesLine_ds.reread();
3137 if (salesLine.RecVersion != versionBeforeUpdate)
3138 {
3139 element.mcrRefreshMarginAlert();
3140 salesLine_ds.refresh();
3141 }
3142 }
3143
3144 /// <summary>
3145 /// Updates the <c>SalesTable</c> delivery address.
3146 /// </summary>
3147 protected void updateSalesTableDeliveryAddress()
3148 {
3149 var salesTableInteractionHelper = SalesTableInteractionHelper::construct();
3150
3151 //salesTableInteractionHelper.updateSalesDeliveryAddressForPickupInStore(SalesTable);
3152 }
3153
3154 /// <summary>
3155 /// Updates the <c>SalesTable</c> delivery address.
3156 /// </summary>
3157 protected void updateSalesLineDeliveryAddress()
3158 {
3159 var salesTableInteractionHelper = SalesTableInteractionHelper::construct();
3160
3161 //salesTableInteractionHelper.updateLineDeliveryAddressForPickupInStore(SalesLine);
3162 }
3163
3164 /// <summary>
3165 /// Determines whether the <c>MCRInventSearch</c> logic is enabled.
3166 /// </summary>
3167 /// <returns>true if the <c>MCRInventSearch</c> logic is enabled; otherwise, false.</returns>
3168 protected boolean isMCRInventSearchEnabled()
3169 {
3170 return isConfigurationkeyEnabled(configurationKeyNum(TradeItemSearch)) && !productFromLookup;
3171 }
3172
3173 /// <summary>
3174 /// Initializing <c>TmpPurchLinePrice</c> table buffer from <c>SalesLine</c> table record.
3175 /// </summary>
3176 /// <param name = "_tmpPurchLinePrice">
3177 /// A <c>TmpPurchLinePrice</c> table buffer.
3178 /// </param>
3179 /// <param name = "_salesLine">
3180 /// A <c>SalesLine</c> table buffer.
3181 /// </param>
3182 protected void initializeTmpPurchLinePriceFromSalesLine(TmpPurchLinePrice _tmpPurchLinePrice)
3183 {
3184 _tmpPurchLinePrice.AccountNum = salesLine.inventTable().PrimaryVendorId;
3185 _tmpPurchLinePrice.SalesId = salesLine.SalesId;
3186 _tmpPurchLinePrice.ItemId = salesLine.ItemId;
3187 _tmpPurchLinePrice.InventDimId = salesLine.InventDimId;
3188 _tmpPurchLinePrice.SalesLineRefRecId = salesLine.RecId;
3189 _tmpPurchLinePrice.Included = NoYes::Yes;
3190 }
3191
3192 /// <summary>
3193 /// Determines whether the caller form is valid for creating new sales order.
3194 /// </summary>
3195 /// <returns>
3196 /// true if caller form is not allowed create new sales order; otherwise, false.
3197 /// </returns>
3198 protected boolean mustCreateSalesOrder()
3199 {
3200 // If we are called from CustomerService and we already have
3201 // created a Sales Order do NOT allow ctrl-n.
3202 if (salesTable.SalesId && mcrCustomerServiceParm)
3203 {
3204 return true;
3205 }
3206
3207 // Refactored logic to run do not allow open order logic in a separate method.
3208 // Need to know whether or not the new create was allowed, if it is not
3209 // return out of the create function.
3210 if (!element.mcrCheckOpenOrder())
3211 {
3212 return true;
3213 }
3214
3215 return false;
3216 }
3217
3218 /// <summary>
3219 /// Creates new sales orders.
3220 /// </summary>
3221 protected void createSalesOrder()
3222 {
3223
3224 salesTable.insert();
3225 }
3226
3227 [DataSource]
3228 class SalesTable
3229 {
3230 /// <summary>
3231 /// Displays the Route associated with the Sales order, if applicable.
3232 /// </summary>
3233 /// <returns>
3234 /// The Route code if there is only one associated with the order, otherwise an empty string or "Multiple".
3235 /// </returns>
3236 public display TMSRouteCode tmsDisplayRouteCode()
3237 {
3238 return salesTableForm.tmsDisplayRouteCode(salesTable);
3239 }
3240
3241 /// <summary>
3242 /// Prompts the user for a reason code when overriding the discount percent field.
3243 /// </summary>
3244 /// <returns>
3245 /// true if the discount percent can be changed; otherwise, false.
3246 /// </returns>
3247 public boolean mcrGetOverrideResponse()
3248 {
3249 boolean currentUserPermission;
3250 container userIdReasonCode;
3251 MCROverrideLogin mcrOverrideLogin;
3252 Args args;
3253 RetailInformationSubcodeId reasonCode;
3254 boolean cancelOverride;
3255
3256 #define.Cancel('Cancel')
3257
3258 // only check override parameters if the system parameter is set to true
3259 if (#MCRPriceOverrideEnabled && enableOrderPriceControl)
3260 {
3261 if (MCRPriceOverrideMarkUpGroup::validatePercent(salesTable.DiscPercent))
3262 {
3263 // See if the current user has permission to override the disc pct. If
3264 // not, call the form for a different user to log in.
3265 mcrOverrideLogin = new MCROverrideLogin();
3266
3267 // Check user's price override permissions. If the user doesn't have
3268 // permission, pop up a dialog.
3269 currentUserPermission = mcrOverrideLogin.isUserValid(curUserId(),
3270 salesTable.DiscPercent,
3271 fieldNum(MCRPriceOverrideMarkUpGroup,
3272 DiscPercentOverride));
3273
3274 // Do not allow the user to manipulate the form while a dialog is open.
3275 element.mcrDisableForm();
3276
3277 // if the current user does not have permission
3278 if (!currentUserPermission)
3279 {
3280 args = mcrOverrideLogin.launchPriceOverrideLogin(salesTable,
3281 NoYes::Yes,
3282 fieldNum(SalesTable, DiscPercent));
3283
3284 // if the user did not cancel out or close using the X with out first getting a valid login
3285 // from the override form it means that someone had a successful override
3286 if (args.parm() != #Cancel)
3287 {
3288 mcrSalesTable.PriceOverride = NoYes::Yes;
3289 // the args.parm passes out user id and reason code
3290 userIdReasonCode = str2con(args.parm());
3291 element.mcrHeaderPriceOverride(false,
3292 conPeek(userIdReasonCode,2),
3293 conPeek(userIdReasonCode,1));
3294 }
3295 else
3296 {
3297 cancelOverride = true;
3298 }
3299 }
3300 else //if current user can override the price.
3301 {
3302 reasonCode = mcrOverrideLogin.launchPriceOverrideReasonCode(salesTable,
3303 NoYes::Yes);
3304 if (reasonCode != #Cancel)
3305 {
3306 mcrSalesTable.PriceOverride = NoYes::Yes;
3307 element.mcrHeaderPriceOverride(false,
3308 reasonCode,
3309 curUserId());
3310 }
3311 else
3312 {
3313 cancelOverride = true;
3314 }
3315 }
3316 element.mcrEnableForm();
3317 }
3318 else
3319 {
3320 cancelOverride = true;
3321 }
3322
3323 element.mcrSetHeaderControls();
3324 }
3325
3326 return !cancelOverride;
3327 }
3328
3329 public boolean leaveRecord(boolean _forceUpdate = false)
3330 {
3331 boolean ret;
3332
3333 salesTable.PackedExtensions = salesTable.orig().PackedExtensions;
3334
3335 ret = super(_forceUpdate);
3336
3337 if (mcrCallCenterEnabled)
3338 {
3339 mcrParmsSet = false;
3340 }
3341 return ret;
3342 }
3343
3344 display public NoYes isRetailOrder()
3345 {
3346 return isRetailOrder;
3347 }
3348
3349 boolean validateDelete()
3350 {
3351 boolean ret;
3352
3353 // Are you sure you want to delete replacement order? A return order is attached.
3354 if (salesTable.ReturnItemNum && SalesTable::findReturnItemNum(salesTable.ReturnItemNum).ReturnReplacementId == salesTable.SalesId
3355 && Box::yesNo("@SYS106592", DialogButton::No) == DialogButton::No)
3356 {
3357 ret = false;
3358 }
3359 else if (mcrCallCenterEnabled && MCRCustPaymTable::hasPrePayment(salesTable.RecId, salesTable.TableId))
3360 {
3361 warning("@RET4493");
3362 ret = false;
3363 }
3364 else
3365 {
3366 ret = super();
3367 }
3368
3369 return ret;
3370 }
3371
3372 void setTouched()
3373 {
3374 // required by form MarkupTrans to communicate changes to the caller
3375 salesTableForm.setTouched(salesTable);
3376 }
3377
3378 public void reRead()
3379 {
3380 if (salesTableType)
3381 {
3382 salesTableType.formMethodDataSourceDelete(element, salesTable_ds, true);
3383 }
3384
3385 // <GTH>
3386 if (isSalesTableExtensionTHEnabled)
3387 {
3388 SalesTableExtensionTH_ds.reread();
3389 }
3390 // </GTH>
3391
3392 super();
3393 }
3394
3395 boolean validateWrite()
3396 {
3397 boolean ret;
3398 // <GEERU>
3399 List salesTable2LineUpdateFields;
3400 ListEnumerator salesTable2LineUpdateFieldsEnumerator;
3401 SalesTable2LineField salesTable2LineField;
3402 // </GEERU>
3403
3404 ret = super();
3405
3406 if (ret && !salesTable.Touched)
3407 {
3408 ret = salesTable.checkUpdate(true, this.performIntercompanyValidation());
3409 }
3410
3411 if (ret && salesTableType && !salesTableType.formMethodDataSourceValidateWrite(element, salesTable_ds))
3412 {
3413 ret = false;
3414 }
3415
3416 if (ret && salesTable.DeliveryDateControlType)
3417 {
3418 ret = SalesCalcAvailableDlvDates::validateWritePromptOnServer(salesTable);
3419 }
3420
3421 copyTaxGroupToMarkupTrans = DialogButton::No;
3422 if (ret && salesTable.TaxGroup != salesTable.orig().TaxGroup)
3423 {
3424 copyTaxGroupToMarkupTrans = MarkupTrans::promptCopyTaxGroupToMarkupTrans(salesTable.TableId, salesTable.RecId);
3425 ret = copyTaxGroupToMarkupTrans != DialogButton::Cancel;
3426 }
3427
3428 if (ret)
3429 {
3430 salesTable2LineUpdatePrompt = SalesTable2LineUpdatePrompt::newFromSalesTableWithMarkupParams(salesTable, copyTaxGroupToMarkupTrans);
3431 ret = salesTable2LineUpdatePrompt.extendedPrompt();
3432
3433 updateSalesLineSourceId = updateSalesLineSourceId && ret;
3434
3435 if (!infolog.parmLastActivatedForm())
3436 {
3437 infolog.setLastActivatedForm(element);
3438 }
3439 }
3440
3441 // <GEERU>
3442 if (isRU
3443 && ret
3444 && salesTable2LineUpdatePrompt)
3445 {
3446 salesTable2LineUpdateFields = List::create(salesTable2LineUpdatePrompt.packedSalesTable2LineUpdateFields());
3447 salesTable2LineUpdateFieldsEnumerator = salesTable2LineUpdateFields.getEnumerator();
3448
3449 while (salesTable2LineUpdateFieldsEnumerator.moveNext())
3450 {
3451 salesTable2LineField = salesTable2LineUpdateFieldsEnumerator.current();
3452
3453 if (salesTable2LineField.fieldId() == fieldNum(SalesTable_RU, InventProfileId_RU) &&
3454 salesTable2LineField.updateSalesLines() == NoYes::No)
3455 {
3456 // must be checked for possible inconsistence if user did not select to propagate inventProfileId to the order lines
3457 // otherwise it will be checked on sales order validateWrite() method
3458 ret = salesTable.checkInventProfile_RU(true);
3459 }
3460 }
3461 }
3462 // </GEERU>
3463
3464 // If the line is part of a Retail Channel sales order, then perform delivery mode validation.
3465 if(ret && salesTable.retailSalesTable().RetailChannel)
3466 {
3467 ret = RetailShippingDeliveryMode::validateHeaderDeliveryOptions(SalesTable);
3468 }
3469
3470 return ret;
3471 }
3472
3473 void write()
3474 {
3475 boolean copyThirdPartyBillingAddress;
3476 boolean convertCurrency = false;
3477 TradeCurencyConversion tradeCurencyConversion = TradeCurencyConversion::ExchRate;
3478 boolean salesLineExists;
3479 boolean markupTransExists;
3480 boolean mustReread;
3481 MCRCustPaymTotals mcrCustPaymTotals;
3482 SalesLine salesLineLocal;
3483 TMSSalesTable newTMSSalesTable;
3484
3485 // <GEEPL>
3486 RefRecId serviceTariffNumber;
3487 // </GEEPL>
3488
3489 RetailSalesOrderCalculatorCache::removeCachedSalesLineForSalesOrder(salesTable);
3490 salesLineExists = SalesLine::exist(salesTable.SalesId);
3491 markupTransExists = MarkupTrans::exist(salesTable.TableId, salesTable.RecId);
3492 if (salesLineExists || markupTransExists)
3493 {
3494 if (salesTable.CurrencyCode != salesTable.orig().CurrencyCode)
3495 {
3496 // If one or more payments disallows changing the currency,
3497 // do not perform the currency conversion.
3498 mcrCustPaymTotals = MCRCustPaymTotals::construct(salesTable.TableId, salesTable.RecId);
3499
3500 if (mcrCustPaymTotals && !mcrCustPaymTotals.allowEditCurrency())
3501 {
3502 convertCurrency = false;
3503 }
3504
3505 else
3506 {
3507 [convertCurrency, tradeCurencyConversion] = SalesTable::promptConvertCurrencyCode(salesTable);
3508 }
3509 }
3510 }
3511
3512 if (salesLineExists)
3513 {
3514 if (salesTable.ShipCarrierPostalAddress != salesTable.orig().ShipCarrierPostalAddress)
3515 {
3516 copyThirdPartyBillingAddress = SalesTable::promptCopyThirdPartyBillingAddress() == DialogButton::Yes;
3517 }
3518 }
3519
3520 ttsbegin;
3521
3522 if (salesTable2LineUpdatePrompt)
3523 {
3524 salesTable2LineUpdatePrompt.updateDeliveryDateAndCopyAddress(salesTable.SalesId);
3525 }
3526 if (copyThirdPartyBillingAddress)
3527 {
3528 salesTable.copyThirdPartyBillingAddressToLine();
3529 }
3530
3531 if (salesLineExists || markupTransExists)
3532 {
3533 if (convertCurrency)
3534 {
3535 salesTable.convertCurrencyCode(salesTable.CurrencyCode, tradeCurencyConversion);
3536 }
3537 else
3538 {
3539 // Cancel has been chosen in the Convert Currency Code dialogue:
3540 // No attempts to recalc currency code should be made;
3541 // All changes made to the currency code have to be rolled back;
3542 // No additional warnings should be issued concerning currency code change operation.
3543 if (salesTable.CurrencyCode != salesTable.orig().CurrencyCode)
3544 {
3545 salesTable.CurrencyCode = salesTable.orig().CurrencyCode;
3546 }
3547 }
3548
3549 if (mcrCallCenterEnabled && updateSalesLineSourceId)
3550 {
3551 element.mcrUpdateSourceIdToSalesLines();
3552 }
3553 }
3554
3555 salesTable.Touched = NoYes::No;
3556
3557 if (salesTableType)
3558 {
3559 salesTableType.formMethodDataSourceWrite(element, salesTable_ds);
3560 }
3561
3562 if (copyTaxGroupToMarkupTrans == DialogButton::Yes || copyTaxGroupToMarkupTrans == DialogButton::YesToAll)
3563 {
3564 MarkupTrans::updateTaxGroup(salesTable.TableId, salesTable.RecId, salesTable.TaxGroup, salesTable.orig().TaxGroup, copyTaxGroupToMarkupTrans);
3565 copyTaxGroupToMarkupTrans = DialogButton::No;
3566 }
3567
3568 // <GEEPL>
3569 serviceTariffNumber = taxServiceTariffHeader.ServiceTariffNumber;
3570 // </GEEPL>
3571 //<GTH>
3572 if (TaxThaiGovCertificationFeatureChecker::isTaxBranchEnabled())
3573 {
3574 salesTableExtensionTH.TaxBranch = TaxBranchType::getTaxBranchRecIdByDefaultDimension(salesTable.DefaultDimension);
3575 }
3576 //</GTH>
3577 //Save off the original value of the DiscPercent in case it has been changed.
3578 //If it has been changed, an order event will be written after the call to super().
3579 mcrHeaderPriceOverrideDiscPct = salesTable.orig().DiscPercent;
3580
3581 super();
3582
3583 // <GEECZ>
3584 if (SysExtensionSerializerExtensionMap::isExtensionEnabled(tableNum(SalesTable_Intrastat)))
3585 {
3586 salesTable_Intrastat.SysExtensionSerializerExtensionMap::insertAfterBaseTable(salesTable);
3587 }
3588 // </GEECZ>
3589
3590 // <GBR>
3591 if (BrazilParameters::isEnabled())
3592 {
3593 salesTable_BR.SysExtensionSerializerExtensionMap::insertAfterBaseTable(salesTable);
3594 }
3595 // </GBR>
3596
3597 // <GEEPL>
3598 // The service tariff relationship is lost during the super() call
3599 // from write since it is on a different data source. So, copy
3600 // the original value back in to ensure saving is done correctly.
3601 if (serviceTariffNumber && countryRegion_PL)
3602 {
3603 taxServiceTariffHeader.ServiceTariffNumber = serviceTariffNumber;
3604 taxServiceTariffHeader.ParentRecId = salesTable.RecId;
3605 taxServiceTariffHeader.ParentTableId = salesTable.TableId;
3606 }
3607 // </GEEPL>
3608
3609 if (isSalesTableExtensionTHEnabled)
3610 {
3611 salesTableExtensionTH.SysExtensionSerializerExtensionMap::insertAfterBaseTable(salesTable);
3612 }
3613
3614 salesTableForm.salesTable(salesTable);
3615
3616 mustReread = element.updateSalesLinesWithPrompt();
3617
3618 if (#MCRPriceOverrideEnabled)
3619 {
3620 // Write order event if total discount has been overridden.
3621 if (mcrHeaderPriceOverrideUserId
3622 && salesTable.DiscPercent != mcrHeaderPriceOverrideDiscPct)
3623 {
3624 element.mcrInsertPriceOverrideOrderEvent();
3625 mcrHeaderPriceOverrideDiscPct = salesTable.DiscPercent;
3626 }
3627 }
3628
3629 ttscommit;
3630
3631 reverseCharge.headerDSPostWrite();
3632
3633 if (mustReread)
3634 {
3635 // If updating header and there are no salesLines, don't research so the line being created isn't lost.
3636 // Will still lose blank salesLine if a salesLine has already been saved
3637 select firstonly salesLineLocal
3638 where salesLineLocal.SalesId == salesTable.SalesId;
3639 if (salesLineLocal
3640 || (! salesLineLocal && salesLine))
3641 {
3642 salesLine_ds.research(true);
3643 }
3644 }
3645
3646 salesTableType = null;
3647
3648 element.refreshRetailDatasource();
3649
3650 if (!tmsSalesTable.isTmp()) // No need to query for TMSSalesTable if it is disabled
3651 {
3652 newTMSSalesTable = TMSSalesTable::find(salesTable.SalesId);
3653
3654 tmsSalesTable.data(newTMSSalesTable);
3655 tmsSalesTable.reread();
3656 }
3657
3658 if (headerError)
3659 {
3660 element.gotoLines();
3661 }
3662 // Records that the order has been opened and which one it is.
3663 if (salesTable.SalesStatus == SalesStatus::Backorder
3664 && enableOrderCompletion)
3665 {
3666 openOrderSalesTable = salesTable.data();
3667 }
3668 }
3669
3670 void linkActive()
3671 {
3672 if (skipLinkActive)
3673 {
3674 return;
3675 }
3676
3677 element.salesTableLinkActiveBasedOnDatasource();
3678
3679 if (salesTableForm.linkActive())
3680 {
3681 salesTableForm.salesTable(element.args().record() as SalesTable);
3682 salesTable_ds.query(salesTableForm.querySalesTable(salesTable_ds.query()));
3683 }
3684
3685 if (salesTableType)
3686 {
3687 salesTableType.formMethodDataSourceLinkActive(element, salesTable_ds);
3688 }
3689
3690 // Only run super if this is not a sales order created from customer
3691 // maintenance, otherwise when allow open orders is off, it will launch the pop-up error
3692 // when loading the sales form.
3693 if (!enterOrderFromNewCust)
3694 {
3695 super();
3696 enterOrderFromNewCust = false;
3697 }
3698 linkActiveHeaderExecuted = false;
3699 }
3700
3701 void init()
3702 {
3703 Query query;
3704 QueryBuildRange queryBuildRange;
3705 ProdTable prodTable;
3706 CustTable custTable;
3707
3708 switch (element.args().dataset())
3709 {
3710 case tableNum(ProjTable) :
3711 salesTable_ds.autoQuery(false);
3712 query = new Query();
3713 queryBuildRangeProjId = query.addDataSource(tableNum(SalesTable)).addRange(fieldNum(SalesTable, ProjId));
3714 salesTable_ds.query(query);
3715 break;
3716
3717 case tableNum(CostControlTransCommittedCost) :
3718 salesTable_ds.autoQuery(false);
3719 query = new Query();
3720 queryBuildRangeSalesId = query.addDataSource(tableNum(SalesTable)).addRange(fieldNum(SalesTable, SalesId));
3721 salesTable_ds.query(query);
3722 break;
3723 }
3724
3725 super();
3726
3727 if (mcrCallCenterEnabled)
3728 {
3729 mcrParmsSet = false;
3730 }
3731 if (TradeFormHelper::isCalledFromForm(element.args(), formStr(CustTable))
3732 && element.args().record().TableId == tableNum(CustTable))
3733 {
3734 this.query().dataSourceTable(tableNum(SalesTable)).clearDynalinks();
3735 custTable = element.args().record() as CustTable;
3736 salesTable_ds.query().dataSourceTable(tableNum(SalesTable)).addDynalink(fieldNum(SalesTable, CustAccount),element.args().record(),fieldNum(CustTable, AccountNum));
3737 queryBuildRange = salesTable_ds.query().dataSourceTable(tableNum(SalesTable)).findRange(fieldNum(SalesTable, CustAccount));
3738 if (queryBuildRange)
3739 {
3740 queryBuildRange.value(custTable.AccountNum);
3741 }
3742 }
3743
3744 switch (element.args().dataset())
3745 {
3746 case tableNum(ProdTable) :
3747 prodTable = element.args().record() as ProdTable;
3748 if (prodTable.InventRefType == InventRefType::Sales && prodTable.InventRefId)
3749 {
3750 salesTable_ds.query().dataSourceTable(tableNum(SalesTable)).clearDynalinks();
3751 salesTable_ds.query().dataSourceTable(tableNum(SalesTable)).addDynalink(fieldNum(SalesTable, SalesId),element.args().record(),fieldNum(ProdTable, InventRefId));
3752 queryBuildRange = salesTable_ds.query().dataSourceTable(tableNum(SalesTable)).findRange(fieldNum(SalesTable, SalesStatus));
3753 if (queryBuildRange)
3754 {
3755 queryBuildRange.value(SysQuery::valueUnlimited());
3756 }
3757 }
3758 break;
3759 // For deductions clear link because filter changes (see linkActive)
3760 case tableNum(TAMDeduction) :
3761 salesTable_ds.query().dataSourceTable(tableNum(SalesTable)).clearDynalinks();
3762 break;
3763 }
3764
3765 salesTable_ds.cacheAddMethod(tableMethodStr(SalesTable, editContactPersonName));
3766 // <GEEU>
3767 if (countryRegion_EEU || SysCountryRegionCode::isLegalEntityInCountryRegion([#isoES])
3768 || SysCountryRegionCode::isLegalEntityInCountryRegion([#isoFR]))
3769 {
3770 salesTable_ds.cacheAddMethod(tableMethodStr(SalesTable, editReasonCode), true);
3771 salesTable_ds.cacheAddMethod(tableMethodStr(SalesTable, editReasonComment), true);
3772 }
3773 // </GEEU>
3774
3775 logisticsPostalAddressDeliveryHeader_ds.validTimeStateUpdate(ValidTimeStateUpdate::Correction);
3776 logisticsPostalAddressShipCarrierHeader_ds.validTimeStateUpdate(ValidTimeStateUpdate::Correction);
3777
3778 logisticsPostalAddressDeliveryHeader_ds.query().validTimeStateDateTimeRange(DateTimeUtil::minValue(),
3779 DateTimeUtil::maxValue());
3780 logisticsPostalAddressShipCarrierHeader_ds.query().validTimeStateDateTimeRange(DateTimeUtil::minValue(),
3781 DateTimeUtil::maxValue());
3782 // <GEERU>
3783 if (isRU)
3784 {
3785 salesTable_ds.cacheAddMethod(tableMethodStr(SalesTable, agreementDocumentTitle_RU), true);
3786 }
3787 // </GEERU>
3788 }
3789
3790 void delete()
3791 {
3792 if (salesTableType)
3793 {
3794 salesTableType.formMethodDataSourceDelete(element, salesTable_ds);
3795 }
3796
3797 if (mcrCallCenterEnabled)
3798 {
3799 // Need to know when the exchange order was deleted
3800 if (returnProcessing && salesTable.ReturnReplacementId)
3801 {
3802 // Need to know the user deleted.
3803 element.args().parm('ExchangeDeleted');
3804 }
3805
3806 // Prevent leave method from firing on a delete which
3807 // was setting invalid errors.
3808 deleting = true;
3809 }
3810
3811 super();
3812
3813 if (mcrCallCenterEnabled)
3814 {
3815 deleting = false;
3816 element.mcrCloseDownOrderEntry();
3817 }
3818 }
3819
3820 void create(boolean append = true)
3821 {
3822 TMSSalesTable newTMSSalesTable;
3823 MCRSalesTable newMCRSalesTable;
3824 MCRSalesTableShipping newMCRSalesTableShipping;
3825 MCRSourceCode mcrSourceCode;
3826 CustTable custTableLocal;
3827
3828 salesTableForm.interCompanyAutoCreateOrders();
3829
3830 element.editSales(true);
3831
3832 // Set cursor to current record when needed
3833 if (newButtonCurrentSalesId && (newButtonCurrentSalesId != salesTable.SalesId))
3834 {
3835 SalesTable currentRecord = SalesTable::find(newButtonCurrentSalesId);
3836 if (currentRecord)
3837 {
3838 this.positionToRecord(currentRecord);
3839 }
3840 }
3841
3842 mcrParmsSet = false;
3843
3844 if (element.mustCreateSalesOrder())
3845 {
3846 return;
3847 }
3848
3849 // If we were called from CustomerService or CustTable and we need to
3850 // create a new Sales Order do it here and not in SalesCreateOrder.
3851 // Added new parameter of FormOpenModeForNew
3852 if (mcrCustomerServiceParm != MCRCustomerServiceParam::None
3853 && mcrCustomerServiceParm != MCRCustomerServiceParam::Add
3854 && mcrCustomerServiceParm != MCRCustomerServiceParam::FormOpenModeForNew)
3855 {
3856 if (element.args().record().TableId == tableNum(CustTable))
3857 {
3858 custTableLocal = element.args().record();
3859 }
3860 salesCreateOrderForm = SalesCreateOrderForm::construct(salesTableForm.defaultSalesType(),
3861 salesTableForm.project());
3862 // When coming from cust service or cust maintenance, open form in simple mode.
3863 if (!salesTable.SalesId)
3864 {
3865 super(append);
3866
3867 if (!salesTableType)
3868 {
3869 salesTableType = salesTable.type();
3870 }
3871
3872 //Only setfocus if on the correct form view
3873 if (tabPageDetails.isDisplayed())
3874 {
3875 lineViewTab.setFocus();
3876 }
3877 salesTableType.formMethodDataSourceCreate(element, salesTable_ds);
3878
3879 salesTable.CustAccount = custTableLocal.AccountNum;
3880
3881 salesTable.transferCustAccount();
3882
3883 ttsbegin;
3884
3885 salesTableType.formMethodDataSourceWrite(element, salesTable_ds);
3886 if (salesTable.ProjId)
3887 {
3888 salesTable.initFromProjInvoiceTable();
3889 }
3890
3891 element.createSalesOrder();
3892
3893 // Records that the order has been opened and which one it is.
3894 if (enableOrderCompletion)
3895 {
3896 openOrderSalesTable = salesTable.data();
3897 }
3898
3899 ttscommit;
3900
3901 if (isSalesTableExtensionTHEnabled || isSalesTableWEnabled)
3902 {
3903 salesTable_DS.research(true);
3904 }
3905
3906 // If creating a sales order from a new customer from CustTable
3907 if (mcrCustomerServiceParm == MCRCustomerServiceParam::CreateNew)
3908 {
3909 mcrSalesTable.SourceId = custTableLocal.mcrCustTable().OrigSourceId;
3910
3911 mcrLastSourceId = mcrSalesTable.SourceId;
3912
3913 ttsbegin;
3914 SalesTable::find(salesTable.SalesId, true);
3915 mcrSourceCode = MCRSourceCode::construct(salesTable);
3916 mcrSourceCode.mcrInitFromSourceCodeSetup(MCRSourceCodeSetup::find(mcrSalesTable.SourceId), salesTable.CustAccount);
3917 salesTable.update();
3918 ttscommit;
3919
3920 salesTable_ds.refresh();
3921 // Immediately refresh the sales line
3922 salesLine_ds.executeQuery();
3923 salesLine_ds.refresh();
3924 }
3925 // Set field as touched so that when a user clicks off that record,
3926 // validateWrite is called.
3927 this.forceWrite(true);
3928 }
3929 }
3930 else
3931 {
3932 if (salesTableForm.create())
3933 {
3934 SalesTable newSalesTable = salesTableForm.salesTable();
3935
3936 if (newSalesTable)
3937 {
3938 if (skipLinkActive)
3939 {
3940 skipLinkActive = false;
3941
3942 if (!linkActiveHeaderExecuted)
3943 {
3944 this.linkActive();
3945
3946 salesTable.data(newSalesTable);
3947 salesTable_ds.setCurrent();
3948 }
3949 }
3950 else
3951 {
3952 super(append);
3953
3954 salesTable.data(newSalesTable);
3955 SalesTable.SysExtensionSerializerMap::UnpackAll(true);
3956 salesTable_ds.setCurrent();
3957 }
3958
3959 salesTable_ds.cacheCalculateMethod(tableMethodStr(SalesTable, editContactPersonName));
3960 salesTable_DS.rereadReferenceDataSources();
3961
3962 element.salesTableCreated();
3963
3964 lineViewTab.setFocus();
3965
3966 // Context is now editing. If FormOpenMode is ForNew, change it to ForEdit
3967 if (TradeFormHelper::isOpenedForNew(element.args()))
3968 {
3969 element.args().parmEnum(enum2int(FormOpenMode::ForEdit));
3970 }
3971
3972 salesLine.clear();
3973 logisticsPostalAddressDeliveryLine.clear();
3974 }
3975 else
3976 {
3977 if (skipLinkActive)
3978 {
3979 skipLinkActive = false;
3980
3981 if (!linkActiveHeaderExecuted)
3982 {
3983 this.linkActive();
3984 }
3985 }
3986 }
3987 }
3988 else
3989 {
3990 // If form was opened for the intent of creating new record, and with the given caller, then close form
3991 if (TradeFormHelper::isOpenedForNewFromForm(element.args()))
3992 {
3993 element.close();
3994 }
3995 else
3996 {
3997 element.editSales(salesTableForm.editHeaderAllowed(), salesTableForm.deleteHeaderAllowed());
3998 }
3999 }
4000 }
4001
4002 if (!tmsSalesTable.isTmp()) // No need to query for TMSSalesTable if it is disabled
4003 {
4004 newTMSSalesTable = TMSSalesTable::find(salesTable.SalesId);
4005
4006 tmsSalesTable.data(newTMSSalesTable);
4007 tmsSalesTable.reread();
4008 }
4009
4010 isRetailOrder = element.useRetailPricingEngine();
4011 mcrCallCenterOrder = salesTable.mcrIsCallCenter();
4012 element.refreshRetailDatasource();
4013
4014 if (mcrCallCenterEnabled)
4015 {
4016 newMCRSalesTable = MCRSalesTable::findSalesId(salesTable.SalesId);
4017 if (newMCRSalesTable)
4018 {
4019 mcrSalesTable.data(newMCRSalesTable);
4020 }
4021
4022 newMCRSalesTableShipping = MCRSalesTableShipping::findSalesId(salesTable.SalesId);
4023 if (newMCRSalesTableShipping)
4024 {
4025 mcrSalesTableShipping.data(newMCRSalesTableShipping);
4026 }
4027
4028 // If the create is being done from customer maintenance via customer service and
4029 // allowOpenOrders is off, then set the boolean to true so that we will not run
4030 // salesTable/LinkActive/Super which tries to save the salesTable record and prompts
4031 // that there can not be open orders.
4032 if (mcrCustomerServiceParm == MCRCustomerServiceParam::CreateNew
4033 && enableOrderCompletion)
4034 {
4035 enterOrderFromNewCust = true;
4036 }
4037
4038 // For when new sales orders are created to set focus to the line.
4039 if (! (MCROrderParameters::find().mcrSourceCodeRequired && mcrSalesTable.SourceId == '')
4040 && salesLine_ItemId.isDisplayed()) //Only setfocus if on the correct form view
4041 {
4042 salesLine_ItemId.setFocus();
4043 }
4044 }
4045 skipLinkActive = false;
4046 }
4047
4048 private void enableTMSActions(boolean _enable)
4049 {
4050 TMS.enabled(_enable);
4051 TabHeaderTMS.enabled(_enable);
4052 }
4053
4054 int active()
4055 {
4056 int ret;
4057 SalesTableType editSalesTableType;
4058 SalesTotals salesTotals;
4059 boolean allowEditDeliveryPostalAddress;
4060 container origPackedExtensions = salesTable.PackedExtensions;
4061
4062 // Allow the invoice account to be edited only if allowed to be changed
4063 // for all payments (or if the sales order is new).
4064 MCRCustPaymTotals mcrCustPaymTotals;
4065 boolean allowEditInvoiceAccount;
4066
4067 performIntercompanyValidationCache = UnknownNoYes::Unknown;
4068
4069 mcrLastSourceId = mcrSalesTable.SourceId;
4070
4071 if (isConfigurationkeyEnabled(configurationKeyNum(MCRCallCenter)))
4072 {
4073 element.mcrOrderEntryModeInit();
4074 }
4075 mcrCallCenterOrder = salesTable.mcrIsCallCenter();
4076 element.editSales(salesTableForm.editHeaderAllowed());
4077
4078 ret = super();
4079
4080 isRetailOrder = element.useRetailPricingEngine();
4081 this.enableRetailFields(isRetailOrder);
4082
4083 this.enableTMSActions(salesTable.canUseTMSActions());
4084
4085 editSalesTableType = salesTable.type();
4086 salesTableForm.salesTable(salesTable);
4087 salesTableForm.enableAvailableDlvDatesButtons(salesTable, salesAvailableDlvDatesHeader, salesAvailableDlvDatesLine, salesLine.LineDeliveryType);
4088
4089 // </GEERU>
4090
4091 // <GIN>
4092 if (SysCountryRegionCode::isLegalEntityInCountryRegion([#isoIN]))
4093 {
4094 salesTableForm.enableExportOrderButton_IN(
4095 salesTable,
4096 createExportOrder_IN);
4097 }
4098 if (isIN)
4099 {
4100 SalesTable_W salesTable_W_Tmp = salesTable.salesTable_W();
4101
4102 ECommerce_IN_ECommerceOperator_IN.enabled(salesTable_W_Tmp.eCommerceSale_IN == NoYes::Yes);
4103 ECommerce_IN_ECommerceOperatorGSTIN_IN.enabled(salesTable_W_Tmp.eCommerceSale_IN == NoYes::Yes);
4104 ECommerce_IN_MerchantID_IN.enabled(salesTable_W_Tmp.eCommerceSale_IN == NoYes::Yes);
4105 }
4106 // </GIN>
4107 // Enables or disables the sales order fields.
4108 if ((salesTable.SalesType == SalesType::ReturnItem && !isReturnFieldsEnabled)
4109 || (salesTable.SalesType != SalesType::ReturnItem && isReturnFieldsEnabled))
4110 {
4111 element.setReturnFields();
4112 isReturnFieldsEnabled = !isReturnFieldsEnabled;
4113 }
4114 if (enableOrderCompletion)
4115 {
4116 mcrCustPaymTotals = MCRCustPaymTotals::construct(salesTable.TableId, salesTable.RecId);
4117 allowEditInvoiceAccount = !salesTable || mcrCustPaymTotals.allowEditInvoiceAccount();
4118 }
4119
4120 // Change visibility through form method
4121 element.mcrVisibleControl(interCompanyAllowIndirectCreationOrig,
4122 salesTable.interCompanyAllowIndirectCreationOrig() ? true : false);
4123
4124 element.mcrSetHeaderControls();
4125
4126 buttonLineQuickQuote. enabled(salesTableForm.editHeaderAllowed());
4127
4128 createCase.enabled(salesTable.RecId != 0);
4129 caseButton.enabled(salesTable.RecId != 0);
4130
4131 if (!enableOrderCompletion)
4132 {
4133 element.editSales(salesTableForm.editHeaderAllowed());
4134 }
4135
4136 salesTable_ds.object(fieldNum(SalesTable, CustAccount) ).allowEdit(editSalesTableType.editCustAccount());
4137 salesTable_ds.object(fieldNum(SalesTable, InvoiceAccount)).allowEdit(editSalesTableType.editInvoiceAccount());
4138 salesTable_ds.object(fieldNum(SalesTable, vatNum) ).allowEdit(editSalesTableType.editVATNum());
4139 salesTable_ds.object(fieldNum(SalesTable, InclTax) ).allowEdit(editSalesTableType.editInclTax());
4140
4141 salesTable_ds.object(fieldNum(SalesTable, DlvMode) ).mandatory(salesTable.dlvModeMandatory());
4142
4143 salesTable_ds.object(fieldNum(SalesTable, CurrencyCode) ).allowEdit(editSalesTableType.editCurrencyCode());
4144 salesTable_ds.object(fieldNum(SalesTable, CurrencyCode) ).skip(!editSalesTableType.editCurrencyCode());
4145
4146 // Currency_M_editReportingCurrencyFixedExchangeRate.allowEdit(editSalesTableType.canEditReportingCurrencyFixedExchangeRate());
4147
4148 salesTable_ds.rereadReferenceDataSources();
4149 element.showHeaderLogisticsPostalEffectiveAddressMessage();
4150
4151 if (tmpSalesTableTaxTransForm && !tmpSalesTableTaxTransForm.closed())
4152 {
4153 //If the tax window is already showing this documents taxes then don't recalculate.
4154 if (tmpSalesTableTaxTransForm.getHeadingRecId() != salesTable.RecId)
4155 {
4156 salesTotals = SalesTotals::construct(salesTable);
4157 salesTotals.calc();
4158 tmpSalesTableTaxTransForm.pushTaxObject(salesTotals.tax());
4159 }
4160 }
4161
4162 // <GIN>
4163 if (TaxWithholdParameters_IN::checkTaxParameters())
4164 {
4165 if (tmpSalesTableTaxWithholdTransForm && !tmpSalesTableTaxWithholdTransForm.closed())
4166 {
4167 salesTotals = SalesTotals::construct(salesTable);
4168 salesTotals.calc();
4169 tmpSalesTableTaxWithholdTransForm.pushTaxObject(salesTotals.taxWithhold_IN());
4170 }
4171 }
4172 // </GIN>
4173 salesTableForm.interCompanySetHeaderAccess(interCompanyAllowIndirectCreationOrig);
4174
4175 if (isConfigurationkeyEnabled(configurationKeyNum(PDS)))
4176 {
4177 salesTableForm.pdsSetHeaderAccess();
4178 }
4179 // <GBR>
4180 if (BrazilParameters::isEnabled())
4181 {
4182 allowEditDeliveryPostalAddress = salesTable_ds.object(fieldNum(SalesTable,DeliveryPostalAddress)).allowEdit(!salesTable.returnItem());
4183 }
4184 else
4185 {
4186 // </GBR>
4187 allowEditDeliveryPostalAddress = salesTable_ds.object(fieldNum(SalesTable,DeliveryPostalAddress)).allowEdit();
4188 // <GBR>
4189 }
4190 // </GBR>
4191
4192 dirPartyPostalAddressNewHeader.enabled(allowEditDeliveryPostalAddress);
4193
4194 //eInvoice. visible(CustTable::isCustDKPublic(salesTable.InvoiceAccount));
4195 eInvoiceLine.visible(CustTable::isCustDKPublic(salesTable.InvoiceAccount));
4196
4197 this.showDimAccount();
4198
4199 headerInquiry_CostControlCommittedCost.enabled(salesTable.ProjId ? true : false);
4200
4201 element.configBankDocumentControls();
4202
4203 // <GIN>
4204 if (isIndiaIndirectTaxParameterMarked)
4205 {
4206 customsExportAssessableValue_IN.enabled(salesTable.CustomsExportOrder_IN == NoYes::Yes && TaxParameters::find().Customs_IN == NoYes::Yes);
4207 salesLine_CustomsMaxRetailPrice_IN.visible(SalesTable::find(salesTable.SalesId).CustomsExportOrder_IN == NoYes::Yes && TaxParameters::find().Customs_IN == NoYes::Yes);//51568
4208 salesLine_MaximumRetailPrice_IN.enabled(SalesTable::find(salesLine.SalesId).CustomsExportOrder_IN == NoYes::No);
4209 }
4210 if (isIndiaWHTMarked)
4211 {
4212 element.setTaxWithholdEnabled_IN();
4213 element.setReturnFields_IN();
4214 }
4215 // </GIN>
4216
4217 // <GBR>
4218 if (BrazilParameters::isEnabled())
4219 {
4220 salesTable_BR_DS.enableDataSourceFields_BR();
4221 }
4222 // </GBR>
4223
4224 // <GEEPL>
4225 headerPackageParm.enabled(! salesTable.ProjId);
4226 linePackageParm.enabled (! salesTable.ProjId);
4227 // </GEEPL>
4228
4229 tieredCharges.enabled(salesTable.markupAllowed());
4230 salesTable.PackedExtensions = origPackedExtensions;
4231
4232 //<GTH>
4233 if (isUnrealizedVATEnabled)
4234 {
4235 element.noteFormatEdit();
4236 }
4237 //</GTH>
4238
4239 CustDirectDebitMandate::defaultAndDisplayMandate(
4240 salesTable.InvoiceAccount,
4241 salesTable.PaymMode,
4242 salesTable.DirectDebitMandate,
4243 false,
4244 salesTable_ds,
4245 fieldNum(SalesTable, DirectDebitMandate));
4246
4247 if (enableDirectedSelling
4248 && mcrCallCenterEnabled
4249 && !SalesLine::exist(salesTable.SalesId))
4250 {
4251 //no salesline yet so override this value
4252 element.mcrDisplayStartOrderMessage(true);
4253 }
4254
4255 if (mcrGiftCardPoliciesEnabled)
4256 {
4257 giftCardPolicyCache = MCRSalesOrderGiftCardPolicyHelper::construct(salesTable.CurrencyCode);
4258 }
4259
4260 if (this.isRetailOrder())
4261 {
4262 SalesTable_RetailChannel.visible(true);
4263 }
4264
4265 if(salesTable.SalesType == SalesType::Sales
4266 && isRetailOrder)
4267 {
4268 ButtonRetailCouponUsage.enabled(true);
4269 }
4270
4271 if (mcrCallCenterOrder && mcrCallCenterEnabled && enableOrderPriceControl)
4272 {
4273 workflowStatusIcon.visible(true);
4274 SalesLine_LineAmount.allowEdit(false);
4275 MCRPriceOverride.visible(true);
4276 SalesTable::mcrUpdatePriceOverrideOnHold(salesTable.SalesId); // need to check again if a line is deleted
4277 }
4278 else
4279 {
4280 element.design().workflowEnabled(false);
4281 }
4282
4283 element.updateExternalWorkOrderStatusVisibility();
4284
4285 return ret;
4286 }
4287
4288 public void displayOption(Common _record, FormRowDisplayOption _options)
4289 {
4290 MCRHoldOrderDisplayColor mcrHoldOrderDisplayColor;
4291
4292 SalesTable salesTableLocal = _record;
4293
4294 mcrHoldOrderDisplayColor = SalesParameters::find().mcrHoldOrderDisplayColor;
4295
4296 if (salesTableLocal)
4297 {
4298 if (mcrHoldOrderDisplayColor
4299 && MCRHoldCodeTrans::findActiveOrderHolds(salesTableLocal.SalesId))
4300 {
4301 _options.backColor(mcrHoldOrderDisplayColor);
4302 }
4303 else
4304 {
4305 _options.clearBackColor();
4306 }
4307 }
4308
4309 super(_record, _options);
4310 }
4311
4312 void editHeader()
4313 {
4314 this.editSales();
4315 }
4316
4317 void editSales()
4318 {
4319 element.editSales(salesTableForm.editHeaderAllowed(), salesTableForm.deleteHeaderAllowed());
4320 element.mcrSetHeaderControls();
4321 element.mcrSetLineControls();
4322 }
4323
4324 public int first()
4325 {
4326 int ret;
4327
4328 // Selects the first record on the sales table. This is not allowed if the user has
4329 // opened an order and open orders are not allowed due to the order completion process being enabled.
4330 if (enableOrderCompletion
4331 && openOrderSalesTable)
4332 {
4333 return ret;
4334 }
4335
4336 ret = super();
4337
4338 return ret;
4339 }
4340
4341 public int last()
4342 {
4343 int ret;
4344
4345 // Selects the last record on the sales table. This is not allowed if the user has
4346 // opened an order and open orders are not allowed.
4347 if (enableOrderCompletion
4348 && openOrderSalesTable)
4349 {
4350 return ret;
4351 }
4352 ret = super();
4353
4354 return ret;
4355 }
4356
4357 void reReadLines()
4358 {
4359 salesLine_ds.executeQuery();
4360 }
4361
4362 public boolean leave()
4363 {
4364 boolean ret;
4365
4366 ret = super();
4367
4368 // Prevent leave method from firing on a delete
4369 if (deleting)
4370 {
4371 return ret;
4372 }
4373 salesTableForm.interCompanyAutoCreateOrders();
4374
4375 // if the status of the order being evaluated has had
4376 // its status changed to something other than open order
4377 // (backorder) clear out the buffer which indicates an open order.
4378 if (enableOrderCompletion)
4379 {
4380 element.mcrCheckOpenOrder();
4381
4382 salesTable_ds.reread();
4383 }
4384
4385 return ret;
4386 }
4387
4388 public void showDimAccount()
4389 {
4390 boolean NOEnabled = salesTable.ProjId && CustTable::isCustPublic_NO(SalesTable.InvoiceAccount);
4391
4392 //eInvoice_EInvoiceLineSpec.visible(!NOEnabled);
4393 //eInvoice_EInvoiceAccountCode.enabled(NOEnabled || !salesTable.eInvoiceLineSpec);
4394 eInvoiceLine_EInvoiceAccountCode.enabled(NOEnabled || salesTable.eInvoiceLineSpec);
4395 eInvoiceLine_OrderLineReference_NO.enabled(NOEnabled || salesTable.eInvoiceLineSpec);
4396 }
4397
4398 void checkCreditLimit()
4399 {
4400 SalesUpdate qtySpec = element.salesUpdateFromTypeOfCreditmaxCheck();
4401
4402 SalesTotals salesTotals = SalesTotals::construct(salesTable, qtySpec);
4403
4404 salesTable.checkCreditLimit(salesTotals);
4405 }
4406
4407 public int next()
4408 {
4409 int ret;
4410 // Selects the next record on the sales table. This is not allowed if the user has
4411 // opened an order and open orders are not allowed.
4412 if (enableOrderCompletion
4413 && openOrderSalesTable)
4414 {
4415 return ret;
4416 }
4417
4418 ret = super();
4419 // integer that represents the next record
4420 return ret;
4421 }
4422
4423 /// <summary>
4424 /// Selects the first record on the next page of the sales table. This is not
4425 /// allowed if the user has opened an order and open orders are not allowed.
4426 /// </summary>
4427 /// <param name="_pageSize">
4428 /// Page size
4429 /// </param>
4430 /// <returns>
4431 /// Returns an integer representing page size.
4432 /// </returns>
4433 public int nextPage(int _pageSize)
4434 {
4435 int ret;
4436
4437 if (enableOrderCompletion
4438 && openOrderSalesTable)
4439 {
4440 _pageSize = 0;
4441 }
4442 ret = super(_pageSize);
4443
4444 return ret;
4445 }
4446
4447 public int prev()
4448 {
4449 int ret;
4450 // Selects the previous record on the sales table. This is not allowed if the user has
4451 // opened an order and open orders are not allowed.
4452 if (enableOrderCompletion
4453 && openOrderSalesTable)
4454 {
4455 return ret;
4456 }
4457 ret = super();
4458 // integer that represents the next record
4459 return ret;
4460 }
4461
4462 public int prevPage(int _pageSize)
4463 {
4464 int ret;
4465
4466 // Selects the first record on the last page of the sales table. This is not
4467 // allowed if the user has opened an order and open orders are not allowed.
4468 if (enableOrderCompletion
4469 && openOrderSalesTable)
4470 {
4471 _pageSize = 0;
4472 }
4473 ret = super(_pageSize);
4474
4475 return ret;
4476 }
4477
4478 void refreshDDC()
4479 {
4480 if (salesTable_ds && salesTable && salesTable.DeliveryDateControlType)
4481 {
4482 salesTable_ds.refresh();
4483 }
4484 }
4485
4486 /// <summary>
4487 /// Checks should intercompany validation be performed for the current sales order.
4488 /// </summary>
4489 /// <returns>
4490 /// true if intercompany validation is necessary; otherwise, false.
4491 /// </returns>
4492 public boolean performIntercompanyValidation()
4493 {
4494 if (performIntercompanyValidationCache == UnknownNoYes::Unknown)
4495 {
4496 performIntercompanyValidationCache = salesTable.isInterCompanyOrder() || InterCompanyPurchSalesReference::isSalesTableReferenced(salesTable.SalesId)
4497 ? UnknownNoYes::Yes
4498 : UnknownNoYes::No;
4499 }
4500
4501 return performIntercompanyValidationCache == UnknownNoYes::No ? false : true;
4502 }
4503
4504 /// <summary>
4505 /// Makes manual discount percentage field visible and disable <c>SalesLine</c> discount fields.
4506 /// </summary>
4507 /// <param name="_enableRetailDiscountFields">
4508 /// The flag to enable disable specific fields.
4509 /// </param>
4510 /// <remarks>
4511 /// Use for retail orders.
4512 /// </remarks>
4513 private void enableRetailFields(boolean _enableRetailDiscountFields)
4514 {
4515 salesLine_ds.object(fieldNum(SalesLine, LineDisc)).enabled(!_enableRetailDiscountFields);
4516 salesLine_ds.object(fieldNum(SalesLine, LinePercent)).enabled(!_enableRetailDiscountFields);
4517 salesLine_ds.object(fieldNum(SalesLine, PriceUnit)).enabled(!_enableRetailDiscountFields);
4518
4519 salesTable_ds.object(fieldNum(SalesTable, DiscPercent)).visible(!_enableRetailDiscountFields);
4520 retailSalesTable_ds.object(fieldNum(RetailSalesTable, TotalManualDiscountPercentage)).visible(_enableRetailDiscountFields);
4521
4522 retailSalesLine_ds.object(fieldNum(RetailSalesLine, LineManualDiscountPercentage)).visible(_enableRetailDiscountFields);
4523
4524 buttonRetailRecalculator.enabled(_enableRetailDiscountFields);
4525
4526 RetailGroupLineView.visible(_enableRetailDiscountFields);
4527 RetailGroupHeaderView.visible(_enableRetailDiscountFields);
4528 AffiliationsButtonGroup.enabled(_enableRetailDiscountFields);
4529
4530 // Only disable Discount fields from Payment Group
4531 Payment_CashDisc.visible(!_enableRetailDiscountFields);
4532 Payment_CashDiscBaseDate.visible(!_enableRetailDiscountFields);
4533 Payment_CashDiscPercent.visible(!_enableRetailDiscountFields);
4534 }
4535
4536 public TitleFields parentTitleFields(Common _record)
4537 {
4538 // Avoid showing ID of initial order for which the form was opened
4539 return '';
4540 }
4541
4542 /// <summary>
4543 /// Updated ECommerce field and control.
4544 /// </summary>
4545 public void updateECommerce_IN()
4546 {
4547 if (isIN)
4548 {
4549 TaxInformationCustTable_IN taxInformationCustTableIN = TaxInformationCustTable_IN::findByCustTable(salesTable.CustAccount);
4550 if (taxInformationCustTableIN.DefaultECommerceOperator)
4551 {
4552 salesTable_W.eCommerceSale_IN = NoYes::Yes;
4553 ECommerce_IN_ECommerceOperator_IN.enabled(true);
4554 ECommerce_IN_ECommerceOperatorGSTIN_IN.enabled(true);
4555 ECommerce_IN_MerchantID_IN.enabled(true);
4556 salesTable_W.eCommerceOperator_IN = taxInformationCustTableIN.DefaultECommerceOperator;
4557 salesTable_W.MerchantID_IN = TaxInformationCustTable_IN::findByCustTable(salesTable_W.eCommerceOperator_IN).MerchantID;
4558 salesTable_W.eCommerceOperatorGSTIN_IN = TaxInformation_IN::findDefaultbyLocation(DirPartyLocation::findPrimaryPartyLocation(CustTable::find(taxInformationCustTableIN.DefaultECommerceOperator).Party).Location).gstin;
4559 }
4560 else
4561 {
4562 salesTable_W.eCommerceSale_IN = NoYes::No;
4563 ECommerce_IN_ECommerceOperator_IN.enabled(false);
4564 ECommerce_IN_ECommerceOperatorGSTIN_IN.enabled(false);
4565 ECommerce_IN_MerchantID_IN.enabled(false);
4566 salesTable_W.eCommerceOperator_IN = '';
4567 salesTable_W.MerchantID_IN = '';
4568 salesTable_W.eCommerceOperatorGSTIN_IN = 0;
4569 }
4570 salesTable_W_ds.refresh();
4571 }
4572 }
4573
4574 [DataField]
4575 class BankAccount_LV
4576 {
4577 public void lookup(FormControl _formControl, str _filterStr)
4578 {
4579 if (BankParameters::checkCurrCodeControl_W())
4580 {
4581 BankAccountTable::lookupGiroBank_W(_formControl, CompanyInfoHelper::standardCurrency());
4582 }
4583 else
4584 {
4585 super(_formControl, _filterStr);
4586 }
4587 }
4588
4589 }
4590
4591 [DataField]
4592 class BankDocumentType
4593 {
4594 public void modified()
4595 {
4596 super();
4597 element.configBankDocumentControls();
4598 }
4599
4600 }
4601
4602 [DataField]
4603 class ContactPersonId
4604 {
4605 void modified()
4606 {
4607 super();
4608 salesTable_ds.refresh();
4609 }
4610
4611 }
4612
4613 [DataField]
4614 class CurBankAccount_LV
4615 {
4616 public void lookup(FormControl _formControl, str _filterStr)
4617 {
4618 if (BankParameters::checkCurrCodeControl_W())
4619 {
4620 BankAccountTable::lookupGiroBank_W(_formControl, salesTable.CurrencyCode);
4621 }
4622 else
4623 {
4624 super(_formControl, _filterStr);
4625 }
4626 }
4627
4628 }
4629
4630 [DataField]
4631 class CurrencyCode
4632 {
4633 public void modified()
4634 {
4635 super();
4636
4637 // <GEEU>
4638 salesTable.initBankAccounts_LV();
4639 BankAccountTable::checkDefaultGiroBank_W(salesTable.CurrencyCode);
4640 salesTable_ds.refresh();
4641 // </GEEU>
4642
4643 if (TaxParameters::find().Customs_IN)
4644 {
4645 if (SalesTable::find(salesLine.SalesId).CustomsExportOrder_IN == NoYes::Yes)
4646 {
4647 salesLine_IN.MaximumRetailPrice = CurrencyHelper_IN::customsCurAmount_IN(salesLine_IN.CustomsMaxRetailPrice, salesTable.CurrencyCode, Direction_IN::Export, DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()), false);
4648 }
4649 }
4650 }
4651
4652 }
4653
4654 [DataField]
4655 class CustAccount
4656 {
4657 public boolean validate()
4658 {
4659 boolean ret;
4660 CustTable custTable;
4661
4662 ret = super();
4663 if (mcrCallCenterEnabled)
4664 {
4665 custTable = CustTable::find(salesTable.CustAccount);
4666 // Do not allow a user to manually enter a phantom custAccount.
4667 if (custTable.mcrMergedParent)
4668 {
4669 ret = checkFailed(strFmt("@MCR12337", salesTable.CustAccount, custTable.mcrMergedParent));
4670 }
4671 }
4672 return ret;
4673 }
4674
4675 public void lookup(FormControl _formControl, str _filterStr = "")
4676 {
4677 if (mcrCallCenterEnabled)
4678 {
4679 CustTable::lookupCustomer(_formControl, curExt(), CustTableLookupDisplayType::MultilineAddress);
4680 }
4681 else
4682 {
4683 super(_formControl, _filterStr);
4684 }
4685 }
4686
4687 public void modified()
4688 {
4689 MCRCustPaymTable mcrCustPaymTableCount;
4690
4691 if (mcrCallCenterEnabled)
4692 {
4693 // Invoice account has changed so back out any existing payments
4694 select count(RecId) from mcrCustPaymTableCount
4695 where mcrCustPaymTableCount.RefRecId == salesTable.RecId
4696 && mcrCustPaymTableCount.RefTableId == salesTable.TableId;
4697
4698 // if payment records currently exist
4699 if (mcrCustPaymTableCount.RecId > 0)
4700 {
4701 // Inform user they are about to lose their payment records and ask
4702 // if they wish to continue.
4703 if (Box::yesNo("@MCR12786", DialogButton::Yes) == DialogButton::No)
4704 {
4705 salesTable.CustAccount = salesTable.orig().CustAccount;
4706 salestable_ds.refresh();
4707 return;
4708 }
4709 }
4710 }
4711
4712 super();
4713
4714 // Update default loyalty card based on the customer.
4715 if (isRetailOrder)
4716 {
4717 RetailLoyaltyCard card = RetailLoyaltyCard::findDefaultLoyaltyCardByCustomer(salesTable.CustAccount);
4718 retailSalesTable.RetailLoyaltyCard = card.RecId;
4719 salesTable.packRetailSalesTable(retailSalesTable);
4720 }
4721
4722 if ((select firstonly salesLine where salesLine.SalesId == salesTable.SalesId).RecId)
4723 {
4724 salesLine_ds.executeQuery();
4725 }
4726
4727 // <GEERU>
4728 if (isRU)
4729 {
4730 salesTable_ds.cacheCalculateMethod(tableMethodStr(SalesTable, agreementDocumentTitle_RU));
4731 }
4732 // </GEERU>
4733
4734 salesTable_ds.cacheCalculateMethod(tableMethodStr(SalesTable, editContactPersonName));
4735 // <GIN>
4736 salesTable_ds.updateECommerce_IN();
4737 // </GIN>
4738 salesTable_ds.refresh();
4739
4740 salesTable_ds.rereadReferenceDataSources();
4741
4742 // <GBR>
4743 if (BrazilParameters::isEnabled())
4744 {
4745 salesTable_BR_ds.refresh();
4746 }
4747 // </GBR>
4748
4749 if (TaxIntegrationUtils::isTaxInformationEnabled())
4750 {
4751 CustTable custTable = CustTable::find(salesTable.CustAccount);
4752 SalesLine salesLineLoc;
4753
4754 while select salesLineLoc
4755 where salesLineLoc.SalesId == salesTable.SalesId
4756 {
4757 TransTaxInformation transTaxInformationLocal = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(salesLine);
4758 if (transTaxInformationLocal)
4759 {
4760 ttsbegin;
4761 transTaxInformationLocal.selectForUpdate(true);
4762 TransTaxInformationHelper::initFromCustVend(transTaxInformationLocal, custTable);
4763 transTaxInformationLocal.update();
4764 ttscommit;
4765 }
4766 }
4767 }
4768 }
4769
4770 }
4771
4772 [DataField]
4773 class DeliveryDateControlType
4774 {
4775 public void modified()
4776 {
4777 super();
4778
4779 salesTable_ds.refreshDDC();
4780 }
4781
4782 }
4783
4784 [DataField]
4785 class DeliveryPostalAddress
4786 {
4787 public void modified()
4788 {
4789 super();
4790
4791 salesTable_ds.refresh();
4792
4793 element.showHeaderLogisticsPostalEffectiveAddressMessage();
4794
4795 // <GBR>
4796 if (BrazilParameters::isEnabled())
4797 {
4798 salesLine_ds.refresh(); // redraw display controls
4799 }
4800 // </GBR>
4801 }
4802
4803 public Common lookupReference(FormReferenceControl _formReferenceControl)
4804 {
4805 Common ret;
4806 CustTable custTable = CustTable::find(salesTable.CustAccount);
4807
4808 ret = LogisticsLocationSelectionLookup::lookupAddressForm(_formReferenceControl, custTable,
4809 [LogisticsLocationRoleType::Delivery],
4810 false,
4811 LogisticsLocationSelectionLookup::transactionAssociatedAddresses(
4812 tableNum(SalesLine),
4813 fieldNum(SalesLine, DeliveryPostalAddress),
4814 fieldNum(SalesLine, SalesId),
4815 salesTable.SalesId,
4816 salesTable.DeliveryPostalAddress),
4817 salesTable);
4818 return ret;
4819 }
4820
4821 }
4822
4823 [DataField]
4824 class DiscPercent
4825 {
4826 public boolean validate()
4827 {
4828 boolean ret = super();
4829
4830 if (ret && mcrCallCenterEnabled && enableOrderPriceControl)
4831 {
4832 ret = salesTable_ds.mcrGetOverrideResponse();
4833 }
4834
4835 return ret;
4836 }
4837
4838 public void modified()
4839 {
4840 super();
4841 }
4842
4843 }
4844
4845 [DataField]
4846 class DlvMode
4847 {
4848 public void modified()
4849 {
4850 MCRExpedite mcrExpedite = DlvMode::find(salesTable.DlvMode).mcrExpedite;
4851
4852 super();
4853
4854 if (mcrSalesTableShipping.Expedite != mcrExpedite)
4855 {
4856 mcrSalesTableShipping.Expedite = mcrExpedite;
4857 salesTable.mcrPackMCRSalesTableShipping(mcrSalesTableShipping);
4858 }
4859
4860 salesTable_ds.refreshDDC();
4861
4862 element.tmsSetCarrierFieldsFromDlvMode(salesTable.DlvMode);
4863
4864 element.enableTMSFields();
4865 element.updateSalesTableDeliveryAddress();
4866
4867 }
4868
4869 public void lookup(FormControl _formControl, str _filterStr)
4870 {
4871 if (SalesTable.retailSalesTable().RetailChannel)
4872 {
4873 RetailShippingDeliveryMode::lookupValidHeaderRetailDeliveryModes(_formControl, SalesTable);
4874 }
4875 else
4876 {
4877 super(_formControl, _filterStr);
4878 }
4879 }
4880
4881 }
4882
4883 [DataField]
4884 class EInvoiceLineSpec
4885 {
4886 public void modified()
4887 {
4888 super();
4889
4890 salesTable_ds.showDimAccount();
4891 }
4892
4893 }
4894
4895 [DataField]
4896 class FixedDueDate
4897 {
4898 public void modified()
4899 {
4900 super();
4901
4902 if (isConfigurationkeyEnabled(configurationKeyNum(PaymCalendar)) && salesTable.FixedDueDate)
4903 {
4904 PaymCalendarAdjustedDate paymCalendarAdjustedDate;
4905
4906 paymCalendarAdjustedDate = PaymCalendarSourceSalesOrder::getAdjustedDate(salesTable);
4907
4908 salesTable.FixedDueDate = PaymCalendarProcessor::getAdjustedDueDate(salesTable.FixedDueDate, priorDueDate, paymCalendarAdjustedDate);
4909 }
4910 }
4911
4912 }
4913
4914 [DataField]
4915 class InterCompanyAutoCreateOrders
4916 {
4917 public void modified()
4918 {
4919 super();
4920
4921 if (salesTable.InterCompanyAutoCreateOrders)
4922 {
4923 salesTableForm.interCompanyAutoCreateOrdersNow(true);
4924 }
4925 }
4926
4927 }
4928
4929 [DataField]
4930 class InventLocationId
4931 {
4932 public void modified()
4933 {
4934 super();
4935
4936 element.updateSalesTableDeliveryAddress();
4937 SalesCalcAvailableDlvDates::initDateFields(salesTable);
4938 salesTable_ds.refresh();
4939 }
4940
4941 public void lookup(FormControl _formControl, str _filterStr)
4942 {
4943 if (salesTable.InventSiteId)
4944 {
4945 InventLocation::lookupBySiteIdAllTypes(_formControl, salesTable.InventSiteId);
4946 }
4947 else
4948 {
4949 super(_formControl, _filterStr);
4950 }
4951 }
4952
4953 }
4954
4955 [DataField]
4956 class InventSiteId
4957 {
4958 public void modified()
4959 {
4960 super();
4961
4962 SalesCalcAvailableDlvDates::initDateFields(salesTable);
4963 salesTable_ds.refresh();
4964 }
4965
4966 }
4967
4968 [DataField]
4969 class InvoiceAccount
4970 {
4971 public boolean validate()
4972 {
4973 boolean ret;
4974 CustTable custTable;
4975
4976 ret = super();
4977
4978 if (mcrCallCenterEnabled)
4979 {
4980 custTable = CustTable::find(salesTable.InvoiceAccount);
4981 if (custTable.mcrMergedParent)
4982 {
4983 ret = false;
4984 }
4985 }
4986 return ret;
4987 }
4988
4989 public void lookup(FormControl _formControl, str _filterStr = "")
4990 {
4991 if (mcrCallCenterEnabled)
4992 {
4993 CustTable::lookupCustomer(_formControl, curExt(), CustTableLookupDisplayType::MultilineAddress);
4994 }
4995 else
4996 {
4997 super(_formControl, _filterStr);
4998 }
4999 }
5000
5001 public void modified()
5002 {
5003 MCRCustPaymTable mcrCustPaymTableLocal;
5004
5005 if (mcrCallCenterEnabled)
5006 {
5007 // If the order was a continuity header and the invoice account was
5008 // changed the related payment was not found because it is not tied to the sales order.
5009 if (mcrSalesTable.ContinuityOrder == NoYes::Yes)
5010 {
5011 SalesTable::mcrUpdateContinuityPayments(salesTable);
5012 }
5013
5014 // Invoice account has changed so back out any existing payments
5015 select count(RecId) from mcrCustPaymTableLocal
5016 where mcrCustPaymTableLocal.RefRecId == salesTable.RecId
5017 && mcrCustPaymTableLocal.RefTableId == salesTable.TableId
5018 && mcrCustPaymTableLocal.CustAccount != salesTable.InvoiceAccount;
5019
5020 // if payment records currently exist
5021 if (mcrCustPaymTableLocal.RecId > 0)
5022 {
5023 // Inform user they are about to loose their payment records and ask
5024 // if they wish to continue.
5025 if (Box::yesNo("@MCR12782",DialogButton::Yes)==DialogButton::No)
5026 {
5027 salesTable.InvoiceAccount = salesTable.orig().InvoiceAccount;
5028 salestable_ds.refresh();
5029 return;
5030 }
5031 }
5032 }
5033
5034 super();
5035
5036 // <GEERU>
5037 if (isRU)
5038 {
5039 salesLine_ds.reread();
5040 salesLine_ds.refresh();
5041 }
5042 // </GEERU>
5043 }
5044
5045 }
5046
5047 [DataField]
5048 class Payment
5049 {
5050 public void modified()
5051 {
5052 super();
5053 salesTable_ds.object(fieldNum(SalesTable, DlvMode)).mandatory(salesTable.dlvModeMandatory());
5054 }
5055
5056 }
5057
5058 [DataField]
5059 class PaymentSched
5060 {
5061 void modified()
5062 {
5063 super();
5064
5065 if (salesTable.PaymentSched)
5066 {
5067 buttonPaymentSchedule.enabled(true);
5068 }
5069 else
5070 {
5071 buttonPaymentSchedule.enabled(false);
5072 }
5073 }
5074
5075 }
5076
5077 [DataField]
5078 class ProjId
5079 {
5080 public void modified()
5081 {
5082 super();
5083
5084 salesTable_ds.showDimAccount();
5085 }
5086
5087 }
5088
5089 [DataField]
5090 class Reservation
5091 {
5092 public void modified()
5093 {
5094 super();
5095
5096 salesTableForm.pdsSetHeaderAccess();
5097 }
5098
5099 }
5100
5101 [DataField]
5102 class ReturnItemNum
5103 {
5104 public void jumpRef()
5105 {
5106 salesTable.jumpRefReturnItemNum(element);
5107 }
5108
5109 }
5110
5111 [DataField]
5112 class SalesType
5113 {
5114 void modified()
5115 {
5116 super();
5117
5118 element.changeType();
5119 }
5120
5121 }
5122
5123 [DataField]
5124 class TCSGroup_IN
5125 {
5126 public void lookup(FormControl _formControl, str _filterStr)
5127 {
5128 TaxWithholdGroupHeading::lookupTaxComponentGroup_IN(_formControl, TaxWithholdCodeType_IN::TCS);
5129 }
5130
5131 public void modified()
5132 {
5133 super();
5134 element.setTaxWithholdEnabled_IN();
5135 }
5136
5137 }
5138
5139 [DataField]
5140 class TDSGroup_IN
5141 {
5142 public void lookup(FormControl _formControl, str _filterStr)
5143 {
5144 TaxWithholdGroupHeading::lookupTaxComponentGroup_IN(_formControl, TaxWithholdCodeType_IN::TDS);
5145 }
5146
5147 public void modified()
5148 {
5149 super();
5150 element.setTaxWithholdEnabled_IN();
5151 }
5152
5153 }
5154
5155 [DataField]
5156 class VATNum
5157 {
5158 public void jumpRef()
5159 {
5160 if (TaxVATNumTable::taxVATNumTableEnabled())
5161 {
5162 TaxVATNumTable::jumpRefVATNum(salesTable, element);
5163 }
5164 else
5165 {
5166 super();
5167 }
5168 }
5169
5170 public void lookup(FormControl _formControl, str _filterStr)
5171 {
5172 if (TaxVATNumTable::taxVATNumTableEnabled())
5173 {
5174 // TaxVATNumTable::lookupVATNum(vatNum,salesTable);
5175 }
5176 else
5177 {
5178 super(_formControl, _filterStr);
5179 }
5180 }
5181
5182 }
5183
5184 [DataField]
5185 class WorkerSalesResponsible
5186 {
5187 public Common lookupReference(FormReferenceControl _formReferenceControl)
5188 {
5189 return HcmWorkerLookup::newOnlyActiveWorkers().lookupWorker(_formReferenceControl);
5190 }
5191
5192 public Common resolveReference(FormReferenceControl _formReferenceControl)
5193 {
5194 Common ret;
5195
5196 ret = super(_formReferenceControl);
5197
5198 if (!ret.RecId || !HcmWorkerLookup::newOnlyActiveWorkers().validateWorker(ret.RecId))
5199 {
5200 ret.clear();
5201 }
5202
5203 return ret;
5204 }
5205
5206 }
5207
5208 [DataField]
5209 class WorkerSalesTaker
5210 {
5211 public Common lookupReference(FormReferenceControl _formReferenceControl)
5212 {
5213 return HcmWorkerLookup::newOnlyActiveWorkers().lookupWorker(_formReferenceControl);
5214 }
5215
5216 public Common resolveReference(FormReferenceControl _formReferenceControl)
5217 {
5218 Common ret;
5219
5220 ret = super(_formReferenceControl);
5221
5222 if (!ret.RecId || !HcmWorkerLookup::newOnlyActiveWorkers().validateWorker(ret.RecId))
5223 {
5224 ret.clear();
5225 }
5226
5227 return ret;
5228 }
5229
5230 }
5231
5232 }
5233
5234 [DataSource]
5235 class SalesLine
5236 {
5237 public void reread()
5238 {
5239 // Current price references may need to be deleted.
5240 salesLine.salesPurchLineInterface().cleanUpPriceHistoryRef();
5241
5242 super();
5243 }
5244
5245 public void updateExplosionCTP()
5246 {
5247 SalesConfirmDatesCommandStrategy confirmDatesStrategy;
5248
5249 if (salesLine.DeliveryDateControlType == SalesDeliveryDateControlType::CTP)
5250 {
5251 this.write(false);
5252
5253 confirmDatesStrategy = SalesConfirmDatesCommandStrategy::newParameters(
5254 salesLine.DeliveryDateControlType,
5255 max(salesLine.ShippingDateRequested, DateTimeUtil::getToday(DateTimeUtil::getUserPreferredTimeZone())),
5256 dateNull(),
5257 true);
5258
5259 confirmDatesStrategy.parmForceReqCalcExplodeCoverageDeletion(true);
5260 confirmDatesStrategy.run(salesLine);
5261 }
5262 }
5263
5264 void create(boolean append = true)
5265 {
5266 // <GEEU>
5267 LineNum lineCount;
5268 // </GEEU>
5269
5270 if (!salesTableForm.canNewLineBeAppended(salesLine))
5271 {
5272 append = false;
5273 }
5274
5275 // Skip intercompany check when creating new line unless current order is intercompany sales order
5276 if (salesTable.checkUpdate(true, salesTable.isInterCompanyOrder()))
5277 {
5278 super(append);
5279 // <GEEU>
5280 if (countryRegion_EEU && !isRU)
5281 {
5282 lineCount = salesTable.lineNumForCreditNote();
5283
5284 if (lineCount > 0)
5285 {
5286 salesLine.LineNum = lineCount;
5287 }
5288 }
5289 // </GEEU>
5290
5291 element.setEditItemOrCategoryAllowed(true);
5292
5293 // filter exist on itemId
5294 if (salesLine.ItemId)
5295 {
5296 this.itemIdModified();
5297 }
5298 // filter exists on SalesCategory
5299 else if (salesLine.SalesCategory)
5300 {
5301 this.changedStockedStatus(true);
5302 }
5303
5304 salesLine_ds.refresh();
5305
5306 //Won't create new salesline if current one was not created correctly
5307 if (!salesLine.ItemId && !salesLine.SalesCategory)
5308 {
5309 salesTableForm.salesLine_Create(salesLine);
5310 }
5311
5312 if (salesTable
5313 && salesLine_ItemId.isDisplayed())
5314 {
5315 salesLine_ItemId.setFocus();
5316 }
5317 }
5318
5319 if (isRetailOrder)
5320 {
5321 RetailSalesOrderCalculatorCache::removeCachedSalesLineForSalesOrder(salesTable);
5322 }
5323 }
5324
5325 public void enableDataSourceFields_BR()
5326 {
5327 boolean enableDeliveryTaxGroups = salesLine.SalesType == SalesType::ItemReq || salesLine_BR.DeliveryCFOPTable_BR;
5328
5329 salesLine_ds.object(fieldNum(SalesLine, DeliveryTaxGroup_BR)).allowEdit(enableDeliveryTaxGroups);
5330 salesLine_ds.object(fieldNum(SalesLine, DeliveryTaxItemGroup_BR)).allowEdit(enableDeliveryTaxGroups);
5331 }
5332
5333 private void initCustInvoiceTrans()
5334 {
5335 Query query;
5336 QueryBuildDataSource qbds;
5337 QueryBuildRange qbr;
5338
5339 query = new Query();
5340 qbds = query.addDataSource(tableNum(CustInvoiceTrans));
5341
5342 qbr = qbds.addRange(fieldNum(CustInvoiceTrans, RecId));
5343 qbr.value(SysQuery::value(salesLine.RefReturnInvoiceTrans_W));
5344
5345 custInvoiceTrans_ds.query(query);
5346 custInvoiceTrans_ds.executeQuery();
5347 }
5348
5349 private void allowEditLine_PL()
5350 {
5351 boolean isCreditNote_PL;
5352
5353 isCreditNote_PL = salesTable.isCreditNote_PL();
5354
5355 salesLine_DS.object(fieldNum(SalesLine, Reservation)).allowEdit(! isCreditNote_PL);
5356
5357 salesLine_DS.object(fieldNum(SalesLine, CreditNoteReasonCode)).allowEdit(isCreditNote_PL);
5358 inventTransPick.enabled(!isCreditNote_PL);
5359
5360 if (salesLine.CreditNoteInternalRef_PL && !salesLine.RefReturnInvoiceTrans_W && !salesLine.ProjId && salesLine.aiExistsOnOriginalInvoice())
5361 {
5362 salesLine_DS.object(fieldNum(SalesLine, SalesQty)).allowEdit (false);
5363 salesLine_DS.object(fieldNum(SalesLine, LineAmount)).allowEdit(false);
5364 }
5365 }
5366
5367 private void active_BR()
5368 {
5369 salesLine_BR_ds.object(fieldNum(SalesLine_BR, TaxServiceCode_BR)).allowEdit(!salesLine_BR.TaxServiceCode_BR);
5370
5371 if (salesLine.ProjId)
5372 {
5373 if (salesLine.SalesType == SalesType::ItemReq)
5374 {
5375 salesLine_BR_ds.object(fieldNum(SalesLine_BR, TaxServiceCode_BR)).allowEdit(false);
5376 }
5377 }
5378
5379 salesLine_BR_DS.enableDataSourceFields_BR();
5380 this.enableDataSourceFields_BR();
5381 }
5382
5383 public void executeQuery()
5384 {
5385 element.resetMarginMap();
5386
5387 super();
5388
5389 if (isCalledFromListPage)
5390 {
5391 isCalledFromListPage = false;
5392 if (salesTable && TradeFormHelper::isEditableNotGridView(element.args()))
5393 {
5394 salesLine_SalesQty.setFocus();
5395 }
5396 }
5397
5398 // focus on the specific line when the page is opened from workflow list page
5399 if (element.args() && element.args().menuItemName() == menuItemDisplayStr(SalesTable_RetailPriceOverrideWorkflow))
5400 {
5401 SalesLine salesLineLocal = element.args().record();
5402
5403 if (salesLineLocal)
5404 {
5405 salesLine_ds.positionToRecord(salesLineLocal);
5406 }
5407 }
5408 }
5409
5410 void enableProjectFields()
5411 {
5412 if (salesLine.ProjId)
5413 {
5414 lineInquiry_CostControlCommittedCost.enabled(true);
5415 salesLine_ds.object(fieldNum(SalesLine, ProjCategoryId)).allowEdit(true);
5416 salesLine_ds.object(fieldNum(SalesLine, ActivityNumber)).allowEdit(true);
5417 }
5418 else
5419 {
5420 lineInquiry_CostControlCommittedCost.enabled(false);
5421 salesLine_ds.object(fieldNum(SalesLine, ProjCategoryId)).allowEdit(false);
5422 salesLine_ds.object(fieldNum(SalesLine, ActivityNumber)).allowEdit(false);
5423 }
5424 }
5425
5426 public boolean validateDelete()
5427 {
5428 boolean ret = true;
5429 str warning = salesLine.type().getDeleteWarning();
5430
5431 if (warning != "")
5432 {
5433 ret = (Box::yesNo(warning, DialogButton::No) == DialogButton::Yes)
5434 && salesLine.validateDelete();
5435 }
5436 else
5437 {
5438 ret = super();
5439 }
5440
5441 return ret && salesLine.checkDelete();
5442 }
5443
5444 /// <summary>
5445 /// Updates the form to reflect the current stocked status, i.e. after a change to the stocked field based on itemid or category field change.
5446 /// </summary>
5447 /// <param name="_resetPrice">
5448 /// A Boolean value that specifies if price should be reset for the line.
5449 /// </param>
5450 void changedStockedStatus(boolean _resetPrice)
5451 {
5452 // Update inventDim with new data which has been set due to modification
5453 inventDim.data(
5454 SalesLineItemIdModifiedDTO::salesLineModifyInvDimAndSetTransQtyUnit(salesLine, _resetPrice));
5455
5456 // Update inventdim fields
5457 element.updateDesign(InventDimFormDesignUpdate::FieldChange);
5458
5459 // Disable category editing if itemid is selected
5460 salesLine_ds.object(fieldNum(SalesLine, SalesCategory)).allowEdit(salesLine.ItemId == '');
5461 // Disable itemid editing if only a category is selected
5462 salesLine_ds.object(fieldNum(SalesLine, ItemId)).allowEdit(!salesLine.isCategoryBased());
5463
5464 // Update allow edit for scrap
5465 element.checkCreditNoteLine();
5466 // Update allow edit for inventory fields
5467
5468 //salesTableForm.pdsSetLineAccessKeepSalesQty(salesLine);
5469 salesTableForm.adjustLineAccessBasedOnItem(salesLine);
5470 // <GEERU>
5471 if (isRU)
5472 {
5473 salesLine_ds.object(fieldNum(SalesLine, AssetId_RU)).allowEdit(salesLine.ItemId &&
5474 InventTable::find(salesLine.ItemId).AssetGroupId_RU != '' ||
5475 salesLine.SalesCategory);
5476 }
5477 // </GEERU>
5478 }
5479
5480 InventDim inventDim()
5481 {
5482 return inventDim;
5483 }
5484
5485 /// <summary>
5486 /// Updates the <c>SalesLine</c> and form based on the item when changed.
5487 /// </summary>
5488 void itemIdModified()
5489 {
5490 SalesLineItemIdModifiedDTO itemIdModifiedDTO = SalesLineItemIdModifiedDTO::construct();
5491
5492 //resetPrice is false here because, it would be called subsequently from changedStockedStatus.
5493 //if an agreement is associated with the SO then reset the price since it won't be reset after the matching agreement line is found.
5494 itemIdModifiedDTO.unpack(
5495 salesLine.itemIdChanged(salesTable.MatchingAgreement !=0, salesTable.MatchingAgreement, true /* perform product variant validation */));
5496
5497 this.changedStockedStatus(false);
5498
5499 if (isConfigurationkeyEnabled(configurationKeyNum(PDS)))
5500 {
5501 salesTableForm.enableLineSalesQtyFields(
5502 salesLine,
5503 salesLine.SalesUnit != '',
5504 itemIdModifiedDTO.parmIsStocked());
5505 }
5506
5507 // If ordering a gift card set the buyer name and email
5508 if (salesLine.ItemId == RetailParameters::find().GiftcardItem)
5509 {
5510 mcrSalesLine.GiftCardBuyerEmail = salesTable.Email;
5511 mcrSalesLine.GiftCardBuyerName = salesTable.SalesName;
5512 }
5513
5514 // Reread ReferenceGroup controls, e.g. to show the category name.
5515 salesLine_ds.rereadReferenceDataSources();
5516
5517 // Refresh view of these two datasources, so they show correct values before line is saved.
5518 // This is not an unused call, doing this makes ds sync with the extension
5519 salesLine.mcrSalesLineDropShipment();
5520 mcrSalesLineDropShipment_ds.refresh();
5521 mcrSalesLine_ds.refresh();
5522
5523 element.findProductNumber();
5524
5525 whsSalesLine.PackingQty = itemIdModifiedDTO.parmWHSPackingQty();
5526
5527 // <GEERU>
5528 element.enableForeignTrade_RU();
5529 // </GEERU>
5530 }
5531
5532 void setTouched()
5533 {
5534 // required by form MarkupTrans to communicate changes to the caller
5535 salesTableForm.setTouched(salesTable);
5536 }
5537
5538 display container lineDeliveryTypeImage(SalesLine _salesLine)
5539 {
5540 switch (_salesLine.LineDeliveryType)
5541 {
5542 case LineDeliveryType::OrderLineWithMultipleDeliveries:
5543 return OrderLineMultipleDeliveriesImageData;
5544 case LineDeliveryType::DeliveryLine:
5545 return DeliveryLineImageData;
5546 default:
5547 return connull();
5548 }
5549 }
5550
5551 void initValue()
5552 {
5553 salesLine.initFromSalesTable(salesTable);
5554
5555 // For category based lines Name should be kept if manually modified.
5556 keepName = false;
5557
5558 super();
5559 }
5560
5561 public void init()
5562 {
5563 super();
5564
5565 salesLine_ds.cacheAddMethod(tableMethodStr(SalesLine, itemName), false);
5566 salesLine_ds.cacheAddMethod(tableMethodStr(SalesLine, timeZoneSite), true);
5567
5568 salesLine_ds.cacheAddMethod(tableMethodStr(SalesLine, whsGetLoads));
5569
5570 if (InventParameters::find().UseQualityManagement)
5571 {
5572 salesLine_ds.cacheAddMethod(tableMethodStr(SalesLine, qualityOrderStatusDisplay), true);
5573 }
5574
5575 if (isConfigurationkeyEnabled(configurationKeyNum(PDS)))
5576 {
5577 this.cacheAddMethod(tableMethodStr(SalesLine, pdsCWUnitId));
5578 }
5579 // <GEEU>
5580 if (countryRegion_EEU)
5581 {
5582 salesLine_ds.cacheAddMethod(tableMethodStr(SalesLine, editReasonCode));
5583 salesLine_ds.cacheAddMethod(tableMethodStr(SalesLine, editReasonComment));
5584 }
5585 // </GEEU>
5586
5587 logisticsPostalAddressDeliveryLine_ds.validTimeStateUpdate(ValidTimeStateUpdate::Correction);
5588 logisticsPostalAddressShipCarrierLine_ds.validTimeStateUpdate(ValidTimeStateUpdate::Correction);
5589
5590 logisticsPostalAddressDeliveryLine_ds.query().validTimeStateDateTimeRange(DateTimeUtil::minValue(),
5591 DateTimeUtil::maxValue());
5592 logisticsPostalAddressShipCarrierLine_ds.query().validTimeStateDateTimeRange(DateTimeUtil::minValue(),
5593 DateTimeUtil::maxValue());
5594 }
5595
5596 FormDataSource salesTable_ds()
5597 {
5598 return salesTable_ds;
5599 }
5600
5601 /// <summary>
5602 /// Writes the SalesLine record.
5603 /// </summary>
5604 /// <param name="_calculateConfirmedDates">
5605 /// A Boolean value indicating whether to calculate confirmed shipping/receipt dates.
5606 /// </param>
5607 void write(boolean _calculateConfirmedDates = true)
5608 {
5609 MCRDropShipment mcrDropShipmentOrigValue = mcrSalesLineDropShipment.orig().DropShipment;
5610
5611 if (!salesTable.checkCreditCard())
5612 {
5613 salesTable_ds.setTouched();
5614 }
5615
5616 SalesTableSalesLineDataSourceWriting salesLineWriting = SalesTableSalesLineDataSourceWriting::newFromSalesLine(salesLine);
5617
5618 boolean priceChanged = salesLineWriting.hasPriceBeenChanged();
5619
5620 MCRInventTable mcrInventTableLocal = salesLineWriting.updateSalesLineContinuityParentData(mcrCallCenterEnabled, mcrSalesLine);
5621
5622 SalesQty origSalesQty_PL = salesLine.orig().SalesQty;
5623
5624 salesLineWriting.updateSaleLineInventDimId(inventDim);
5625
5626 salesTableForm.salesLine_Write(salesLine);
5627
5628 if (copyTaxGroupToMarkupTrans == DialogButton::Yes
5629 || copyTaxGroupToMarkupTrans == DialogButton::YesToAll)
5630 {
5631 salesLineWriting.updateSalesLineTaxGroup(copyTaxGroupToMarkupTrans);
5632 copyTaxGroupToMarkupTrans = DialogButton::No;
5633 }
5634
5635 // Want to know if inserting because will show form for gift certificates
5636 // if inserting but not if modifying.
5637 boolean isInsert = salesLine.RecId == 0;
5638
5639 RefRecId serviceTariffNumber = taxServiceTariffLine.ServiceTariffNumber;
5640
5641 reverseCharge.lineDSPreWrite();
5642
5643 salesLineWriting.markToSyncLinkedPurchaseOrderLine();
5644
5645 element.salesLineDataSourceWriting(salesLine);
5646 SalesStatus originalSalesStatus = salesLine.SalesStatus;
5647
5648 super();
5649
5650 // In case of intercompany auto-create and direct delivery, the mcrSalesLineDropShipment record has already
5651 // been created as result of the intercompany chain creation in the super() call above.
5652 salesLineWriting.copyToSalesLineDropShipment(salesTable, mcrSalesLineDropShipment, mcrSalesLineDropShipment_ds);
5653
5654 this.updatePricingCalculationCache();
5655
5656 salesLineWriting.updateWHSSalesLine(whsSalesLine);
5657
5658 this.insertIntrastatSalesLineData();
5659
5660 this.forceWriteSalesLine_IN();
5661
5662 this.forceWriteMCRSalesLine();
5663
5664 this.forceWriteMCRSalesLineDropShipment(mcrDropShipmentOrigValue);
5665
5666 if (#MCRPriceOverrideEnabled)
5667 {
5668 this.forceWriteMCRSalesLinePriceOverride();
5669 }
5670
5671 salesLine.updateRetailDiscounts();
5672
5673 if(mcrCallCenterEnabled && enableOrderPriceControl)
5674 {
5675 salesLineWriting.updateRetailSalesLine(salesTable, retailSalesLine);
5676 }
5677
5678 // The service tariff relationship is lost during the super() call
5679 // from write since it is on a different data source. So, copy
5680 // the original value back in to ensure saving is done correctly.
5681 if (serviceTariffNumber && countryRegion_PL)
5682 {
5683 this.restoreServiceTariffRelationship(serviceTariffNumber);
5684 }
5685
5686 this.insertSalesLineData_BR();
5687
5688 salesLineWriting.updateForeignTradeCategory(salesLineForeignTradeCategory);
5689
5690 if (countryRegion_EEU && !isRU)
5691 {
5692 salesLineWriting.updateInventoryMarkingForCreditNoteTransaction_PL(origSalesQty_PL);
5693 }
5694
5695 if (isInsert && mcrInventTableLocal.ContinuityScheduleId)
5696 {
5697 salesLineWriting.markAsContinuityParent();
5698 }
5699
5700 boolean returnReplacement = mcrReturnSalesTable.IsExchange && SalesLine::mcrFindReturnLineForExchange(salesLine.InventTransId);
5701
5702 salesLineWriting.copyToInventDim(inventDim, inventDim_ds);
5703
5704 this.insertSalesLineData_IN();
5705 this.insertSalesLineData_W();
5706
5707 salesLineWriting.refreshDeliverySchedule(salesTableForm);
5708
5709 if (_calculateConfirmedDates)
5710 {
5711 salesLineWriting.calculateConfirmedDates(salesTable, salesLine_ds);
5712 }
5713
5714 reverseCharge.lineDSPostWrite();
5715
5716 salesLineWriting.querySalesLineDataSourceForIntercompanyOrder(salesTable, salesLine_ds);
5717
5718 salesTable_ds.reread();
5719 salesTable_ds.refresh();
5720
5721 element.refreshRetailDatasource();
5722
5723 // Lines have changed so salesTable.estimated might need to be re-calculated.
5724 salesTable_ds.setTouched();
5725
5726 salesLineWriting.researchSaleLineDataSource(salesLine_ds);
5727
5728 interCompanyIsPriceDiscSearchNeeded = 0;
5729
5730 this.logInfoMessageIfCashDiscPercentAndCreditNoteLine();
5731
5732 this.setToAutomaticTotalDiscount();
5733
5734 if (#MCRPriceOverrideEnabled
5735 && mcrLinePriceOverrideEventType
5736 && priceChanged)
5737 {
5738 this.writeOrderPriceChangeEvent();
5739 }
5740
5741 // Don't upsell/cross-sell for return replacement lines.
5742 if (!returnReplacement
5743 && isInsert
5744 && mcrCallCenterOrder
5745 && MCRUpSellItem::existItem(salesLine.ItemId))
5746 {
5747 salesLineWriting.promptForAdditionalSalesLinesDueToUpOrCrossSellItems(salesLine_ds);
5748 }
5749
5750 this.recordThatOrderHasBeenOpened();
5751
5752 element.salesLineDataSourceWritten(SalesLine, originalSalesStatus);
5753 }
5754
5755 private void updatePricingCalculationCache()
5756 {
5757 boolean updatePricingCalculationCache = salesLine.RecId == 0;
5758
5759 if (updatePricingCalculationCache)
5760 {
5761 salesTableForm.recalculatePotencyPricingCache(salesLine.RecId, salesLine.ItemId);
5762 }
5763 }
5764
5765 private void insertIntrastatSalesLineData()
5766 {
5767 if (SysExtensionSerializerExtensionMap::isExtensionEnabled(tableNum(SalesLine_Intrastat)))
5768 {
5769 salesLine_Intrastat.SysExtensionSerializerExtensionMap::insertAfterBaseTable(salesLine);
5770 }
5771 }
5772
5773 private void forceWriteSalesLine_IN()
5774 {
5775 if (!salesLine_IN.RecId)
5776 {
5777 // Need to force the write in the create case since the form won't do it.
5778 salesLine_IN.SalesLine = salesLine.RecId;
5779 salesLine_IN_ds.write();
5780 }
5781 }
5782
5783 private void forceWriteMCRSalesLine()
5784 {
5785 if (!mcrSalesLine.RecId)
5786 {
5787 // Need to force the write in the create case since the form won't do it.
5788 mcrSalesLine.SalesLine = salesLine.RecId;
5789 mcrSalesLine_ds.write();
5790 }
5791 }
5792
5793 private void forceWriteMCRSalesLineDropShipment(MCRDropShipment _mcrDropShipmentOrigValue)
5794 {
5795 if (!mcrSalesLineDropShipment.RecId && mcrSalesLineDropShipment.DropShipment)
5796 {
5797 mcrSalesLineDropShipment_ds.write();
5798 }
5799
5800 this.deleteDirectDeliveryPurchaseOrder(_mcrDropShipmentOrigValue);
5801 }
5802
5803 private void forceWriteMCRSalesLinePriceOverride()
5804 {
5805 if (!mcrSalesLinePriceOverride.RecId
5806 && (mcrSalesLinePriceOverride.PriceOverride || mcrLinePriceOverrideEventType == MCROrderEventType::SalesLinePriceOverrideTurnedOn))
5807 {
5808 // Need to force the write in the create case since the form won't do it.
5809 mcrSalesLinePriceOverride.SalesLine = salesLine.RecId;
5810 mcrSalesLinePriceOverride_ds.write();
5811 }
5812 }
5813
5814 /// <summary>
5815 /// Restores service tariff relationship.
5816 /// </summary>
5817 /// <param name = "_serviceTariffNumberRecId">A service tariff number record ID.</param>
5818 private void restoreServiceTariffRelationship(RefRecId _serviceTariffNumberRecId)
5819 {
5820 taxServiceTariffLine.ServiceTariffNumber = _serviceTariffNumberRecId;
5821 taxServiceTariffLine.ParentRecId = salesLine.RecId;
5822 taxServiceTariffLine.ParentTableId = salesLine.TableId;
5823 }
5824
5825 private void insertSalesLineData_BR()
5826 {
5827 if (BrazilParameters::isEnabled())
5828 {
5829 salesLine_BR.SysExtensionSerializerExtensionMap::insertAfterBaseTable(salesLine);
5830 }
5831 }
5832
5833 private void insertSalesLineData_IN()
5834 {
5835 if (isSalesLine_INEnabled)
5836 {
5837 salesLine_IN.SysExtensionSerializerExtensionMap::insertAfterBaseTable(salesLine);
5838 }
5839 }
5840
5841 private void insertSalesLineData_W()
5842 {
5843 if (isISOMY)
5844 {
5845 salesLine_W.SysExtensionSerializerExtensionMap::insertAfterBaseTable(salesLine);
5846 }
5847 }
5848
5849 private void logInfoMessageIfCashDiscPercentAndCreditNoteLine()
5850 {
5851 if (salesTable.CashDiscPercent && salesLine.SalesQty < 0)
5852 {
5853 if (salesLine.creditNoteLine())
5854 {
5855 info("@SYS99047");
5856 }
5857 }
5858 }
5859
5860 private void setToAutomaticTotalDiscount()
5861 {
5862 if (salesTable.ProjId)
5863 {
5864 element.automaticTotalDiscount();
5865 }
5866 }
5867
5868 private void writeOrderPriceChangeEvent()
5869 {
5870 // Write the order event for override price if an event around pricing occurred.
5871 MCROrderEventTable mcrOrderEventTableLocal;
5872 mcrOrderEventTableLocal.insertPriceChange(
5873 salesLine.SalesId,
5874 mcrLinePriceOverrideEventType,
5875 mcrLinePriceOverrideUserId,
5876 mcrSalesLinePriceOverride.ListPrice,
5877 mcrSalesLinePriceOverride.ListPriceCurrencyCode,
5878 salesLine.mcrPricePerSalesQty(),
5879 mcrLinePriceOverrideReasonCode,
5880 salesLine.InventTransId);
5881
5882 // Reset event type (otherwise price events continue to be written)
5883 mcrLinePriceOverrideEventType = 0;
5884 }
5885
5886 private void recordThatOrderHasBeenOpened()
5887 {
5888 if (salesTable.SalesStatus == SalesStatus::Backorder
5889 && enableOrderCompletion)
5890 {
5891 openOrderSalesTable = salesTable.data();
5892 }
5893 }
5894
5895 void linkActive()
5896 {
5897 SalesLine salesLineLocal;
5898
5899 // Needed to avoid sales lines changing for seemingly no reason - related to the MCRScriptText and image
5900 if (salesLine)
5901 {
5902 salesLineLocal = salesLine.data();
5903 }
5904
5905 super();
5906
5907 if (salesLineLocal)
5908 {
5909 // Needed to avoid sales lines changing for seemingly no reason - related to the MCRScriptText and image
5910 salesLine_ds.positionToRecord(salesLineLocal);
5911 }
5912
5913 /* Set caption */
5914 if (!salesLine && salesTable && !element.inViewMode())
5915 {
5916 salesTableForm.salesTable(salesTable);
5917 salesLine_ds.create();
5918 }
5919 }
5920
5921 void delete()
5922 {
5923 // Check if it is the temporarily created line. Then no additional action needs to be performed.
5924 if (!salesLine.RecId)
5925 {
5926 super();
5927
5928 return;
5929 }
5930
5931 SalesId salesId;
5932 boolean interCompanySalesLineExist;
5933 // <GEEU>
5934 boolean mustFormResearchAfterDelete = salesTableForm.mustFormResearchAfterDelete(salesLine, salesLine_ds.anyMarked());
5935 // </GEEU>
5936
5937 if (blockSalesLineDelete)
5938 {
5939 return;
5940 }
5941
5942 salesId = salesLine.SalesId;
5943 interCompanySalesLineExist = salesLine.interCompanySalesLineExist();
5944
5945 // Current price references may need to be deleted.
5946 salesLine.salesPurchLineInterface().cleanUpPriceHistoryRef();
5947
5948 reverseCharge.lineDSPreDelete();
5949
5950 //For MCR mandatory configuration item deleting
5951
5952 deleting = true;
5953 super();
5954 deleting = false;
5955
5956 if (!inDeleteMarked)
5957 {
5958 this.retailDiscountReCalculate(salesLine);
5959 }
5960
5961 if (mustFormResearchAfterDelete)
5962 {
5963 salesLine_ds.research(true);
5964 }
5965
5966 if (salesId && SalesTable::exist(salesId))
5967 {
5968 if (SalesParameters::find().DeleteHeading == NoYes::Yes && SalesTable::find(salesId).SalesStatus == SalesStatus::Invoiced)
5969 {
5970 RetailSalesOrderCalculator::setPricesDiscountsOnOrderOnServer(salesTable.SalesId, salesTable.retailSalesTable().TotalManualDiscountPercentage);
5971 salesLine_ds.research(true);
5972 }
5973 else
5974 {
5975 salesTable_ds.reread();
5976 salesTable_ds.refresh();
5977 }
5978 }
5979
5980 // Always make sure it gets refreshed. Certain cases exist where the existing lines will hide if this isn't called
5981 if (!mcrProcessingDeliverySchedule
5982 && this.numberOfRowsLoaded() == 0)
5983 {
5984 salesLine_ds.executeQuery();
5985 }
5986
5987 // Reset the header control
5988 element.mcrSetHeaderControls();
5989
5990 salesTableForm.setTouched(salesTable);
5991
5992 if (salesTable.ProjId)
5993 {
5994 element.automaticTotalDiscount();
5995 }
5996 }
5997
5998 int active(boolean _mcrFormPartUpdateOnly = false)
5999 {
6000 int ret;
6001 boolean returnItem = salesTable.returnItem();
6002 boolean allowEditDeliveryPostalAddress;
6003 boolean isPendingApproval;
6004 boolean isVisibleTabCreditNote = (salesLine.RefReturnInvoiceTrans_W || salesLine.CreditNoteInternalRef_PL);
6005
6006 ret = super();
6007
6008 element.mcrSetLineControls();
6009
6010 if (_mcrFormPartUpdateOnly)
6011 {
6012 return ret;//only do the super to update the form part
6013 }
6014
6015 salesTableForm.salesTable(salesTable);
6016
6017 buttonHeaderTradeAgreements. enabled(!returnItem);
6018
6019 element.setEditItemOrCategoryAllowed(salesLine.RecId == 0);
6020
6021 // <GEEU>
6022 salesLine_ds.allowEdit(salesTableForm.editLineAllowed(salesLine));
6023 // </GEEU>
6024
6025 // If already disabled by setting header controls (Complete/modify buttons) don't allow this to re-enable the salesLine
6026 if (salesLine_ds.allowEdit())
6027 {
6028 salesLine_ds.allowCreate(salesTableForm.createLineAllowed(salesLine));
6029 salesLine_ds.allowDelete(salesTableForm.deleteLineAllowed(salesLine));
6030 }
6031
6032 ResetFulfillmentStatus.enabled(retailSalesLine && retailSalesLine.FulfillmentStatus == RetailFulfillmentLineStatus::Rejected);
6033
6034 // <GEERU>
6035 if (isRU)
6036 {
6037 salesLine_ds.object(fieldNum(SalesLine, AssetId_RU)).allowEdit(
6038 salesLine.canInvoiceOrderLineFromCurrentSalesStatus() &&
6039 (salesLine.ItemId &&
6040 InventTable::find(salesLine.ItemId).AssetGroupId_RU ||
6041 salesLine.SalesCategory));
6042
6043 salesLine_ds.object(fieldNum(SalesLine, LedgerDimension)).allowEdit(element.allowEditLedgerAccount_RU());
6044
6045 element.enableForeignTrade_RU();
6046 }
6047 // </GEERU>
6048
6049 element.checkCreditNoteLine();
6050
6051 element.updateDesign(InventDimFormDesignUpdate::Active);
6052 if (salesLine_ds.object(fieldNum(SalesLine, RetailVariantId)).allowEdit())
6053 {
6054 salesLine_ds.object(fieldNum(SalesLine, RetailVariantId)).allowEdit(salesLine.SalesPurchLine::retailVariantIdAllowEdit());
6055 }
6056
6057 if (headerError)
6058 {
6059 salesTable.Touched = NoYes::Yes;
6060 headerError = false;
6061 }
6062
6063 // <GEEU>
6064 // Credit note
6065 if (countryRegion_EEU && !isRU)
6066 {
6067 this.allowEditLine_PL();
6068 this.initCustInvoiceTrans();
6069
6070 if (tabCreditNote.visible() != isVisibleTabCreditNote)
6071 {
6072 tabCreditNote.visible(isVisibleTabCreditNote);
6073 salesLine_ds.refresh();
6074 }
6075 }
6076 // </GEEU>
6077
6078 salesTableForm.interCompanySetLineAccess(salesLine);
6079
6080 allowEditDeliveryPostalAddress = salesLine_ds.object(fieldNum(SalesLine,DeliveryPostalAddress)).allowEdit();
6081 dirPartyPostalAddressNewLine.enabled(allowEditDeliveryPostalAddress);
6082
6083 salesTableForm.enableAvailableDlvDatesButtons(salesTable, salesAvailableDlvDatesHeader, salesAvailableDlvDatesLine, salesLine.LineDeliveryType);
6084 salesTableForm.enableDeliveryAlternativesButton(salesTable, salesLine, SalesLine_DeliveryDetails);
6085
6086 if (isConfigurationkeyEnabled(configurationKeyNum(PMF)))
6087 {
6088 pmfBatchOrderNew.enabled(element.pmfIsEnabled());
6089 }
6090 buttonLineProduction.enabled(salesLine.inventTable().isBOMAllowed());
6091
6092 salesLine_ds.enableProjectFields();
6093
6094 element.showLineLogisticsPostalEffectiveAddressMessage();
6095
6096 //salesTableForm.pdsSetLineAccessKeepSalesQty(salesLine);
6097 // <GBR>
6098 if (BrazilParameters::isEnabled())
6099 {
6100 this.active_BR();
6101 }
6102 // </GBR>
6103
6104 // <GIN>
6105 if (isIndiaIndirectTaxParameterMarked)
6106 {
6107 element.enableFieldsActive_IN();
6108 element.setTaxWithholdEnabled_IN();
6109 element.setReturnFields_IN();
6110
6111 if (salesTable.CustomsExportOrder_IN
6112 && salesLine.RecId
6113 && salesLine.SalesQty > 0
6114 && TaxParameters::find().EximIncentiveSchemes_IN
6115 && !EximSalesLine_IN::exist(salesLine.RecId))
6116 {
6117 element.setTaxWithholdEnabled_IN();
6118 }
6119 salesLineReturnDetails_IN_ds.enableSalesLineReturnDataSource();
6120 }
6121 // </GIN>
6122
6123 mcrLinePriceOverrideReasonCode = "";
6124 mcrLinePriceOverrideUserId = "";
6125
6126 if (enableDirectedSelling)
6127 {
6128 // Load the messages for this item
6129 element.mcrDisplayItemMessage();
6130 }
6131
6132 // For lines with a continuity item, enable the ContinuitySchedule Button
6133 if (enableOrderCompletion
6134 || (mcrCallCenterOrder && InventTable::mcrIsItemContinuity(salesLine.ItemId)))
6135 {
6136 mcrSalesLine_ContinuityScheduleId.enabled(true);
6137 mcrContinuitySchedule.enabled(true);
6138 }
6139 else
6140 {
6141 mcrSalesLine_ContinuityScheduleId.enabled(false);
6142 mcrContinuitySchedule.enabled(false);
6143 }
6144
6145 onInit = true;
6146
6147 whsWorkTable.enabled(WHSInventEnabled::exist(salesLine.ItemId));
6148 whsSalesLine_PackingQty.enabled(WHSInventEnabled::exist(salesLine.ItemId) || TMSInventEnabled::exist(salesLine.ItemId));
6149
6150 // check to disable the line if the line is pending approval
6151 if(mcrCallCenterEnabled && enableOrderPriceControl)
6152 {
6153 isPendingApproval = mcrSalesLine.RetailPriceOverrideWorkflowState == RetailPriceOverrideWorkflowState::Submitted;
6154
6155 salesLine_ds.allowEdit(!isPendingApproval);
6156 retailSalesLine_ds.allowEdit(!isPendingApproval);
6157 LineStripDelete.enabled(!isPendingApproval);
6158 RetailSalesLine_PriceOverrideReasonCode.mandatory(mcrSalesLine.RetailPriceOverrideWorkflowState != RetailPriceOverrideWorkflowState::None);
6159 }
6160
6161 if(EInvoiceCFDIParameters_MX::isVersionApplicableForForeignTrade())
6162 {
6163 salesLine_ds.object(fieldNum(SalesLine, Samples_MX)).enabled(salesLine.Consignment_MX);
6164 }
6165
6166 if (isRetailOrder)
6167 {
6168 // For retail orders, check whether or not the price should be locked and disallow edits for price locked lines.
6169 boolean isPriceLocked = RetailPricingEngineHelper::isPriceLocked(salesTable, salesLine, retailSalesLine);
6170 salesLine_ds.allowEdit(!isPriceLocked);
6171 }
6172
6173 return ret;
6174 }
6175
6176 public void displayOption(Common _record, FormRowDisplayOption _options)
6177 {
6178 SalesLine salesLineLocal = _record;
6179 int priceOverrideLineColor;
6180
6181 if (#MCRPriceOverrideEnabled)
6182 {
6183 priceOverrideLineColor = mcrOrderParameters.mcrPriceOverrideLineColor;
6184
6185 // if the price was overridden on this line, set the Price Override Line Color from the sales parameter table.
6186 // Child Ship To Lines always have there price overridden by the system - don't display as overridden
6187 // note: child ship to line price cannot be changed & is driven by the parent line.
6188 if (enableOrderPriceControl
6189 && priceOverrideLineColor
6190 && salesLineLocal.LineDeliveryType != LineDeliveryType::DeliveryLine
6191 && salesLineLocal.mcrSalesLinePriceOverride().PriceOverride == NoYes::Yes)
6192 {
6193 _options.backColor(priceOverrideLineColor);
6194 }
6195 else
6196 {
6197 _options.clearBackColor();
6198 }
6199 }
6200
6201 super(_record, _options);
6202 }
6203
6204 /// <summary>
6205 /// Prompts the user for a reason code when overriding price fields.
6206 /// </summary>
6207 /// <param name="_fieldId">
6208 /// The ID of the field being overridden.
6209 /// </param>
6210 /// <param name="_newValue">
6211 /// The new value the user entered.
6212 /// </param>
6213 /// <param name="_overrideFieldId">
6214 /// The ID of the parameter field used to check whether or not the
6215 /// current user has permission.
6216 /// </param>
6217 /// <returns>
6218 /// true if the value can be changed; otherwise, false.
6219 /// </returns>
6220 public boolean mcrGetOverrideResponse(
6221 FieldId _fieldId,
6222 real _newValue,
6223 FieldId _overrideFieldId)
6224 {
6225 MCROverrideLogin_OverridePrice mcrOverrideLogin_OverridePrice;
6226 boolean currentUserPermission;
6227 boolean cancelOverride;
6228 Args args;
6229 container userIdmcrPriceOverrideReasonCode;
6230 RetailInformationSubcodeId mcrPriceOverrideReasonCode;
6231 AmountCur brokerages;
6232 AmountCur rebates;
6233 AmountCur royalties;
6234 AmountCur totalDeductible;
6235 real marginPrice;
6236 MCRMarginAlert_Sales mcrMarginAlert_Sales;
6237
6238 #define.Cancel('Cancel')
6239
6240 if (#MCRPriceOverrideEnabled && enableOrderPriceControl)
6241 {
6242 mcrOverrideLogin_OverridePrice = new MCROverrideLogin_OverridePrice();
6243
6244 // Convert to a percentage based on item cost.
6245 if (_overrideFieldId == fieldNum(MCRPriceOverrideMarkUpGroup, CostMarkUpPercent))
6246 {
6247 mcrMarginAlert_Sales = MCRMarginAlert_Sales::newSalesLine(salesLine);
6248 mcrMarginAlert_Sales.calcMargin();
6249 brokerages = mcrMarginAlert_Sales.parmBrokerAmountPerUnit();
6250 rebates = mcrMarginAlert_Sales.parmCustRebateAmountPerUnit();
6251 royalties = mcrMarginAlert_Sales.parmRoyaltyAmountPerUnit();
6252 totalDeductible = brokerages + rebates + royalties;
6253
6254 _newValue = 100 * mcrOverrideLogin_OverridePrice.calculateCostMarkupPercent(
6255 salesLine.ItemId,
6256 salesLine.InventDimId,
6257 salesLine.SalesUnit,
6258 salesLine.mcrPricePerSalesQty());
6259 marginPrice = 100 * mcrOverrideLogin_OverridePrice.calculateMarginCostMarkupPercent(
6260 salesLine.ItemId,
6261 salesLine.InventDimId,
6262 salesLine.SalesUnit,
6263 salesLine.mcrPricePerSalesQty(),
6264 totalDeductible);
6265 }
6266
6267 // See if the current user has permission to override the price. If they do not
6268 // call the form for a different user to log in.
6269 currentUserPermission = mcrOverrideLogin_OverridePrice.isUserValid(curUserId(),
6270 _newValue,
6271 _overrideFieldId,
6272 marginPrice);
6273 // Do not allow the user to manipulate the form while a dialog is open.
6274 element.mcrDisableForm();
6275
6276 // if the current user does not have permission
6277 if (!currentUserPermission)
6278 {
6279 args = mcrOverrideLogin_OverridePrice.launchPriceOverrideLogin(
6280 salesLine,
6281 NoYes::Yes,
6282 _fieldId);
6283
6284 // if the user did not cancel out or close using the X with out first getting a valid login
6285 // from the override form it means that someone had a successful override
6286 if (args.parm() != #Cancel)
6287 {
6288 // the args.parm passes out user id and reason code
6289 userIdmcrPriceOverrideReasonCode = str2con(args.parm());
6290 element.mcrLinePriceOverrideYes(
6291 conPeek(userIdmcrPriceOverrideReasonCode, 2),
6292 conPeek(userIdmcrPriceOverrideReasonCode, 1));
6293 }
6294 else
6295 {
6296 cancelOverride = true;
6297 }
6298 }
6299 else
6300 {
6301 // If current user can override the price.
6302 mcrPriceOverrideReasonCode = mcrOverrideLogin_OverridePrice.launchPriceOverrideReasonCode(salesLine, NoYes::Yes);
6303 if (mcrPriceOverrideReasonCode != #Cancel)
6304 {
6305 if (_fieldId == fieldNum(RetailSalesLine, LineManualDiscountPercentage))
6306 {
6307 element.mcrLineManualDiscountOverride(mcrPriceOverrideReasonCode, curUserId());
6308 }
6309 else
6310 {
6311 element.mcrLinePriceOverrideYes(mcrPriceOverrideReasonCode, curUserId());
6312 }
6313 }
6314 else
6315 {
6316 cancelOverride = true;
6317 }
6318 }
6319
6320 if (!cancelOverride
6321 && !mcrSalesLinePriceOverride.RecId)
6322 {
6323 mcrSalesLinePriceOverride.ListPrice = (salesLine.LineAmount / (salesLine.SalesQty != 0 ? salesLine.SalesQty : 1));
6324 mcrSalesLinePriceOverride.ListPriceCurrencyCode = salesLine.CurrencyCode;
6325 }
6326
6327 element.mcrEnableForm();
6328
6329 element.mcrSetLineControls();
6330 }
6331
6332 // Return false if it was cancelled, otherwise return true
6333 return !cancelOverride;
6334 }
6335
6336 public boolean validateWrite()
6337 {
6338 boolean ret = true;
6339
6340 salesTableForm.setTouched(salesTable);
6341 salesLine.InventDimId = InventDim::findOrCreate(inventDim).InventDimId;
6342
6343 if (!salesLine.isAgreementLinkValid(true))
6344 {
6345 ret = salesLine.unLinkAgreementLinePrompt(0,tableNum(SalesLine),false);
6346 }
6347
6348 // If DropShipment flag is set on existing sales line ensure McrSalesLineDropShipment is created and invent dim updated
6349 if (salesLine.RecId
6350 && !mcrSalesLineDropShipment.RecId
6351 && mcrSalesLineDropShipment.DropShipment)
6352 {
6353 mcrSalesLineDropShipment.SalesLine = salesLine.RecId;
6354 mcrSaleslineDropShipment.DropShipStatus = MCRDropShipStatus::ToBeDropShipped;
6355
6356 this.updateInventDimForDropShipment();
6357 }
6358
6359 ret = super() && ret;
6360
6361 if (ret)
6362 {
6363 ret = salesTable.checkUpdate(true, salesLine.isInterCompanyOriginalLine());
6364 if (!ret)
6365 {
6366 salesLine_ds.reread();
6367 salesTable_ds.reread();
6368 }
6369 }
6370
6371 copyTaxGroupToMarkupTrans = DialogButton::No;
6372 if (ret && salesLine.TaxGroup != salesLine.orig().TaxGroup)
6373 {
6374 copyTaxGroupToMarkupTrans = MarkupTrans::promptCopyTaxGroupToMarkupTrans(salesLine.TableId, salesLine.RecId);
6375 ret = copyTaxGroupToMarkupTrans != DialogButton::Cancel;
6376 }
6377
6378 if (ret)
6379 {
6380 ret = salesTableForm.salesLine_validateWrite(salesLine, inventDim);
6381 // An alternative item can be applied in the salesTableForm.salesLine_validateWrite() method.
6382 // If the itemId is changed, the form design needs being updated.
6383 if (SalesLine.ItemId != SalesLine.orig().ItemId)
6384 {
6385 element.updateDesign(InventDimFormDesignUpdate::FieldChange);
6386 salesLine_ds.cacheCalculateMethod(tableMethodStr(SalesLine,itemName));
6387 }
6388 }
6389
6390 if (ret && salesLine.DeliveryDateControlType)
6391 {
6392 ret = SalesCalcAvailableDlvDates::validateWritePromptOnServer(salesLine, false, false, true, false);
6393 }
6394
6395 // If the line is part of a Retail Channel sales order, then perform delivery mode validation.
6396 if(ret && SalesLine.salesTable(false).retailSalesTable().RetailChannel && isConfigurationkeyEnabled(configurationKeyNum(TradeMultiShipTo)))
6397 {
6398 ret = RetailShippingDeliveryMode::validateDeliveryOptions(SalesLine);
6399 }
6400
6401 return ret;
6402 }
6403
6404 void refreshDDC()
6405 {
6406 if (salesLine_ds && salesLine && salesLine.DeliveryDateControlType)
6407 {
6408 salesLine_ds.refresh();
6409 }
6410 }
6411
6412 /// <summary>
6413 /// Displays the adjusted net amount.
6414 /// </summary>
6415 /// <param name="_salesLine">
6416 /// A buffer of the sales line record selected on the form.
6417 /// </param>
6418 /// <returns>
6419 /// The adjusted net amount.
6420 /// </returns>
6421 public display PDSCalculatedLineAmount getPotencyCalculatedLineAmount(SalesLine _salesLine)
6422 {
6423 if (_salesLine.ItemId)
6424 {
6425 return salesTableForm.getActiveLineCalculatedAmount(_salesLine.RecId, _salesLine.ItemId);
6426 }
6427 else
6428 {
6429 return 0;
6430 }
6431 }
6432
6433 /// <summary>
6434 /// Displays the adjusted unit price if this is an advanced pricing order.
6435 /// </summary>
6436 /// <param name="_salesLine">
6437 /// A buffer of the sales line record selected on the form.
6438 /// </param>
6439 /// <returns>
6440 /// The adjusted unit price.
6441 /// </returns>
6442 public display PDSCalculatedUnitPrice getPotencyCalculatedUnitPrice(SalesLine _salesLine)
6443 {
6444 if (_salesLine.ItemId)
6445 {
6446 return salesTableForm.getActiveLineCalculatedUnitPrice(_salesLine.RecId, _salesLine.ItemId);
6447 }
6448 else
6449 {
6450 return 0;
6451 }
6452 }
6453
6454 /// <summary>
6455 /// Displays the calculation ID if this is an advanced pricing order.
6456 /// </summary>
6457 /// <param name="_salesLine">
6458 /// A buffer of the sales line record selected on the form.
6459 /// </param>
6460 /// <returns>
6461 /// The calculation ID.
6462 /// </returns>
6463 public display PDSCalculationId getPotencyCalculationId(SalesLine _salesLine)
6464 {
6465 if (_salesLine.ItemId)
6466 {
6467 return salesTableForm.getActiveLineCalculationId(_salesLine.RecId, _salesLine.ItemId);
6468 }
6469 else
6470 {
6471 return '';
6472 }
6473 }
6474
6475 /// <summary>
6476 /// Deletes the related direct delivery purchase order.
6477 /// </summary>
6478 /// <param name = "_mcrDropShipmentOrigValue">The original <c>MCRDropShipment</c> value retrieved from the orig buffer.</c></param>
6479 /// <remarks>
6480 /// This is used for cases when user un-checks the drop shipment flag.
6481 /// </remarks>
6482 protected void deleteDirectDeliveryPurchaseOrder(MCRDropShipment _mcrDropShipmentOrigValue = NoYes::No)
6483 {
6484 if (salesLine
6485 && mcrSalesLineDropShipment
6486 && !mcrSalesLineDropShipment.DropShipment
6487 && _mcrDropShipmentOrigValue)
6488 {
6489 MCRSalesLineDropShipment::deleteRelatedPurchaseOrderLine(salesLine.RecId);
6490 salesLine_ds.reread();
6491 }
6492 }
6493
6494 /// <summary>
6495 /// Returns the margin percent value and margin icon for the sale line.
6496 /// </summary>
6497 /// <param name="_salesLine">
6498 /// A buffer of the sales line record selected on the form.
6499 /// </param>
6500 /// <returns>
6501 /// The margin percent, icon and textual status.
6502 /// </returns>
6503 private container mcrGetMarginValues(SalesLine _salesLine)
6504 {
6505 if (salesParameters.mcrEnableMarginAlert
6506 && _salesLine.InventTransId)
6507 {
6508 // Use the value in the map for performance reasons if exists
6509 if (marginMap.exists(_salesLine.InventTransId))
6510 {
6511 return marginMap.lookup(_salesLine.InventTransId);
6512 }
6513 else
6514 {
6515 str marginIcon;
6516 MCRMarginPecentStr marginPecentStr = _salesLine.mcrDisplayMarginPercentStr();
6517
6518 // If the margin could be calculated then determine the icon
6519 if (_salesLine.McrMarginPercent != McrMarginAlert::percentValueForNotCalculated())
6520 {
6521 marginIcon = MCRMarginAlert::getMarginSymbol(_salesLine.McrMarginPercent);
6522 }
6523 marginMap.insert(_salesLine.InventTransId, [marginPecentStr, marginIcon]);
6524
6525 return [marginPecentStr, marginIcon];
6526 }
6527 }
6528
6529 return conNull();
6530 }
6531
6532 /// <summary>
6533 /// Displays the margin percent value for the sale line.
6534 /// </summary>
6535 /// <param name="_salesLine">
6536 /// A buffer of the sales line record selected on the form.
6537 /// </param>
6538 /// <returns>
6539 /// The margin percent.
6540 /// </returns>
6541 display MCRMarginPecentStr mcrMarginPercentStr(SalesLine _salesLine)
6542 {
6543 container marginAlertValues = this.mcrGetMarginValues(_salesLine);
6544 return conPeek(marginAlertValues, 1);
6545 }
6546
6547 /// <summary>
6548 /// Displays the margin icon value for the sale line.
6549 /// </summary>
6550 /// <param name="_salesLine">
6551 /// A buffer of the sales line record selected on the form.
6552 /// </param>
6553 /// <returns>
6554 /// The margin icon.
6555 /// </returns>
6556 display container mcrMarginIcon(SalesLine _salesLine)
6557 {
6558 SymbolFontGlyphName symbol = conPeek(this.mcrGetMarginValues(_salesLine), 2);
6559 return ImageReference::constructForSymbol(symbol).pack();
6560 }
6561
6562 /// <summary>
6563 /// Updates the InventLocationId and InventSiteId of inventDim if the Drop shipment flag is set
6564 /// </summary>
6565 private void updateInventDimForDropShipment()
6566 {
6567 MCRInventTable mcrInventTableLocal = MCRInventTable::findByItemId(salesLine.ItemId);
6568
6569 if (mcrInventTableLocal.DropShipment)
6570 {
6571 InventTableModule inventTableModule = InventTableModule::find(salesLine.ItemId,ModuleInventPurchSales::Sales);
6572 inventDim.InventLocationId = inventTableModule.inventLocationId();
6573 inventDim.InventSiteId = inventTableModule.inventSiteId();
6574
6575 salesLine.InventDimId = InventDim::findOrCreate(inventDim).InventDimId;
6576 salesLine.modifyInventDim(inventDim,fieldNum(InventDim,InventLocationId));
6577 }
6578 }
6579
6580 /// <summary>
6581 /// If retail order, discount is recalculated after deleting line.
6582 /// </summary>
6583 /// <param name="_salesLine">
6584 /// Sales line record on the grid
6585 /// </param>
6586 private void retailDiscountRecalculate(SalesLine _salesLine)
6587 {
6588 RetailSalesTable retailSales = salesTable.retailSalesTable();
6589
6590 if (RetailParameters::isRetailEnabledAndInUse() &&
6591 RetailPricingEngine::useRetailPricing(_salesLine))
6592 {
6593 RetailSalesOrderCalculator::setPricesDiscountsOnOrderOnServer(salesTable.SalesId, retailSales.TotalManualDiscountPercentage);
6594 salesLine_ds.research(true);
6595 }
6596 }
6597
6598 public void deleteMarked()
6599 {
6600 inDeleteMarked = true;
6601 super();
6602 inDeleteMarked = false;
6603
6604 this.retailDiscountReCalculate(salesLine);
6605 }
6606
6607 /// <summary>
6608 /// If quantity is changed on a sales line, and the line has a linked (not direct delivery, not intercompany) purchase order line, prompts user to determine if
6609 /// linked purchase order line should also be updated.
6610 /// </summary>
6611 /// <returns>true if the linked purchase order should be updated; otherwise, false.</returns>
6612 private boolean updateLinkedPurchaseOrderLineOnQuantityUpdate()
6613 {
6614 if (salesLine.InventRefTransId
6615 && salesLine.InventRefType == InventRefType::Purch
6616 && salesLine.DeliveryType == TradeLineDlvType::None
6617 && salesLine.SalesQty != salesLine.orig().SalesQty
6618 && !PurchTable::find(salesLine.InventRefId).InterCompanyOrder) // For intercompany orders we always sync the quantities, so don't ask.
6619 {
6620 PurchLine purchLine = PurchLine::findInventTransId(salesLine.InventRefTransId);
6621
6622 if (Box::yesNo(strFmt("@SCM:SalesLineQtyChangeUpdateLinkedPurchLine", purchLine.PurchId, purchLine.LineNumber), DialogButton::Yes))
6623 {
6624 return true;
6625 }
6626 }
6627
6628 return false;
6629 }
6630
6631 /// <summary>
6632 /// Check if current line need to be marked as "need to submit for approval".
6633 /// </summary>
6634 public void mcrSetWorkflowApprovalStatus()
6635 {
6636 boolean currentUserPermission;
6637 real newPrice;
6638 real marginPrice;
6639 AmountCur brokerages;
6640 AmountCur rebates;
6641 AmountCur royalties;
6642 AmountCur totalDeductible;
6643 MCRMarginAlert_Sales mcrMarginAlert_Sales;
6644 MCROverrideLogin_OverridePrice mcrOverrideLogin_OverridePrice;
6645 WorkflowWorkItemTable workItem;
6646
6647 mcrOverrideLogin_OverridePrice = new MCROverrideLogin_OverridePrice();
6648
6649 mcrMarginAlert_Sales = MCRMarginAlert_Sales::newSalesLine(salesLine);
6650 mcrMarginAlert_Sales.calcMargin();
6651 brokerages = mcrMarginAlert_Sales.parmBrokerAmountPerUnit();
6652 rebates = mcrMarginAlert_Sales.parmCustRebateAmountPerUnit();
6653 royalties = mcrMarginAlert_Sales.parmRoyaltyAmountPerUnit();
6654 totalDeductible = brokerages + rebates + royalties;
6655
6656 newPrice = 100 * mcrOverrideLogin_OverridePrice.calculateCostMarkupPercent(
6657 salesLine.ItemId,
6658 salesLine.InventDimId,
6659 salesLine.SalesUnit,
6660 salesLine.mcrPricePerSalesQty());
6661 marginPrice = 100 * mcrOverrideLogin_OverridePrice.calculateMarginCostMarkupPercent(
6662 salesLine.ItemId,
6663 salesLine.InventDimId,
6664 salesLine.SalesUnit,
6665 salesLine.mcrPricePerSalesQty(),
6666 totalDeductible);
6667
6668 currentUserPermission = mcrOverrideLogin_OverridePrice.isUserValid(curUserId(),
6669 newPrice,
6670 fieldNum(MCRPriceOverrideMarkUpGroup, CostMarkUpPercent),
6671 marginPrice);
6672
6673 if (!currentUserPermission)
6674 {
6675 if (mcrSalesLine.RetailPriceOverrideWorkflowState != RetailPriceOverrideWorkflowState::Rejected)
6676 {
6677 // cannot use element.getActiveWorkflowWorkItem() because if canSubmitToWorkflow return true, it will return null
6678 select firstonly workItem
6679 where workItem.DocumentClassId == classNum(RetailSalesLineWFTypeDocument)
6680 && workItem.Status == WorkflowWorkItemStatus::Pending
6681 && workItem.Type == WorkflowWorkItemType::Return
6682 && workItem.RefTableId == tableNum(SalesLine)
6683 && workItem.RefRecId == salesLine.RecId;
6684
6685 if (workItem)
6686 {
6687 mcrSalesLine.RetailPriceOverrideWorkflowState = RetailPriceOverrideWorkflowState::Rejected;
6688 }
6689 else
6690 {
6691 mcrSalesLine.RetailPriceOverrideWorkflowState = RetailPriceOverrideWorkflowState::NotSubmitted;
6692 }
6693 }
6694 }
6695 else
6696 {
6697 mcrSalesLine.RetailPriceOverrideWorkflowState = RetailPriceOverrideWorkflowState::None;
6698 }
6699
6700 RetailSalesLine_PriceOverrideReasonCode.mandatory(mcrSalesLine.RetailPriceOverrideWorkflowState != RetailPriceOverrideWorkflowState::None);
6701 }
6702
6703 /// <summary>
6704 /// Displays the brand for the item.
6705 /// </summary>
6706 /// <param name="_salesLine">
6707 /// A buffer of the sales line record selected on the form.
6708 /// </param>
6709 /// <returns>
6710 /// The brand code.
6711 /// </returns>
6712 display BrandCode_MX getItemBrand_MX(SalesLine _salesLine)
6713 {
6714 return _salesLine.inventTable().BrandCodeId_MX;
6715 }
6716
6717 public boolean leave()
6718 {
6719 boolean ret;
6720
6721 ret = super();
6722
6723 RetailSalesOrderCalculatorCache::removeCachedLine(salesLine);
6724
6725 return ret;
6726 }
6727
6728 [DataField]
6729 class ActivityNumber
6730 {
6731 public void lookup(FormControl _formControl, str _filterStr)
6732 {
6733 HierarchyTreeTable::lookupHierarchyTree(_formControl, ProjTable::find(salesLine.ProjId));
6734 }
6735
6736 }
6737
6738 [DataField]
6739 class Consignment_MX
6740 {
6741 public void modified()
6742 {
6743 super();
6744 salesLine_ds.object(fieldNum(SalesLine, Samples_MX)).enabled(salesLine.Consignment_MX);
6745 }
6746
6747 }
6748
6749 [DataField]
6750 class CustAccount
6751 {
6752 public boolean validate()
6753 {
6754 boolean ret;
6755 CustTable custTableLocal;
6756
6757 ret = super();
6758 if (mcrCallCenterEnabled)
6759 {
6760 custTableLocal = CustTable::find(salesTable.CustAccount);
6761 // Do not allow a user to manually enter a phantom custAccount.
6762 if (custTableLocal.mcrMergedRoot)
6763 {
6764 checkFailed(strFmt("@MCR12337", salesTable.CustAccount, custTableLocal.mcrMergedRoot));
6765 // Return the parent account number
6766 salesTable.CustAccount = custTableLocal.mcrMergedRoot;
6767 }
6768 }
6769
6770 return ret;
6771 }
6772
6773 }
6774
6775 [DataField]
6776 class DeliveryPostalAddress
6777 {
6778 public void modified()
6779 {
6780 super();
6781
6782 salesLine_ds.refresh();
6783
6784 element.showLineLogisticsPostalEffectiveAddressMessage();
6785
6786 // <GBR>
6787 if (BrazilParameters::isEnabled())
6788 {
6789 salesLine_ds.refresh(); // redraw display controls
6790 }
6791 // </GBR>
6792 }
6793
6794 public Common lookupReference(FormReferenceControl _formReferenceControl)
6795 {
6796 Common ret;
6797 CustTable custTable = CustTable::find(salesTable.CustAccount);
6798
6799 ret = LogisticsLocationSelectionLookup::lookupAddressForm(_formReferenceControl, custTable,
6800 [LogisticsLocationRoleType::Delivery],
6801 false,
6802 LogisticsLocationSelectionLookup::transactionAssociatedAddresses(
6803 tableNum(SalesLine),
6804 fieldNum(SalesLine, DeliveryPostalAddress),
6805 fieldNum(SalesLine, SalesId),
6806 salesTable.SalesId,
6807 salesTable.DeliveryPostalAddress),
6808 SalesLine_DS.cursor());
6809 return ret;
6810 }
6811
6812 }
6813
6814 [DataField]
6815 class DeliveryType
6816 {
6817 public void modified()
6818 {
6819 element.defaultInventDimBasedOnDirectDeliveryWarehouse(SalesLine.isDirectDelivery());
6820
6821 super();
6822 SalesLine_DS.refresh();
6823
6824 // super call may have deleted a related direct delivery purchase order and thus updated the DropShipStatus back on the SalesLine
6825 MCRSalesLineDropShipment_ds.reread();
6826
6827 if (!SalesLine.isDirectDelivery())
6828 {
6829 MCRSalesLineDropShipment.DropShipment = false;
6830 }
6831 }
6832
6833 }
6834
6835 [DataField]
6836 class DlvMode
6837 {
6838 public void modified()
6839 {
6840 RetailSalesLine.FulfillmentStoreId = SalesLine.mcrGetFulfillmentStore();
6841
6842 super();
6843
6844 element.updateSalesLineDeliveryAddress();
6845 salesLine_ds.refreshDDC();
6846 }
6847
6848 public void lookup(FormControl _formControl, str _filterStr)
6849 {
6850 if (SalesLine.salesTable(false).retailSalesTable().RetailChannel)
6851 {
6852 RetailShippingDeliveryMode::lookupValidRetailDeliveryModes(_formControl, SalesLine);
6853 }
6854 else
6855 {
6856 super(_formControl, _filterStr);
6857 }
6858 }
6859
6860 }
6861
6862 [DataField]
6863 class ExpectedRetQty
6864 {
6865 public void modified()
6866 {
6867 salesLine.InventDimId = InventDim::findOrCreate(inventDim).InventDimId;
6868 super();
6869 }
6870
6871 }
6872
6873 [DataField]
6874 class IntrastatCommodity
6875 {
6876 public Common resolveReference(FormReferenceControl _formReferenceControl)
6877 {
6878 var intrastatCommodityController = IntrastatCommodityController::newFromItemAndCategory(SalesLine.ItemId, SalesLine.SalesCategory);
6879
6880 return intrastatCommodityController.resolveReference(_formReferenceControl);
6881 }
6882
6883 public Common lookupReference(FormReferenceControl _formReferenceControl)
6884 {
6885 var intrastatCommodityController = IntrastatCommodityController::newFromItemAndCategory(SalesLine.ItemId, SalesLine.SalesCategory);
6886
6887 return intrastatCommodityController.lookupReference(_formReferenceControl);
6888 }
6889
6890 }
6891
6892 [DataField]
6893 class InventTransIdReturn
6894 {
6895 public void lookup(FormControl _formControl, str _filterStr)
6896 {
6897 InventTransOrigin::lookupTransIdReturn(_formControl, salesLine, inventDim);
6898 }
6899
6900 public void modified()
6901 {
6902 super();
6903
6904 element.checkCreditNoteLine();
6905 }
6906
6907 }
6908
6909 [DataField]
6910 class ItemBOMId
6911 {
6912 public void lookup(FormControl _formControl, str _filterStr)
6913 {
6914 InventTable::lookupBOMId(_formControl, salesLine.ItemId, inventDim);
6915 }
6916
6917 }
6918
6919 [DataField]
6920 class ItemId
6921 {
6922 public void lookup(FormControl _formControl, str _filterStr)
6923 {
6924 if (mcrCallCenterEnabled && salesLine.mcrSalesLine().SourceId != "")
6925 {
6926 Catalog::lookupItemsFromSourceId(salesLine.mcrSalesLine().SourceId, _formControl, _filterStr);
6927 }
6928 else
6929 {
6930 if (EcoResProductParameters::find().pcLookupMethod == PCLookupMethod::Configurable)
6931 {
6932 Args args = new Args(formStr(PCProductLookup));
6933 args.caller(element);
6934 FormRun formRun = classfactory.formRunClass(args);
6935 formRun.init();
6936 this.performFormLookup(formRun, _formControl);
6937 }
6938 else if (isProductSearchLookupEnabled)
6939 {
6940 EcoResProductSearchLookup::lookupProduct(_formControl as FormStringControl);
6941 }
6942 else
6943 {
6944 SalesLine::lookupItemNumber(_formControl, SalesLine, _filterStr);
6945 }
6946 }
6947 }
6948
6949 void modified()
6950 {
6951 ItemId itemId = salesLine.ItemId;
6952
6953 salesTableForm.resetSalesLine(salesLine);
6954
6955 if (mcrCallCenterEnabled && mcrCallCenterOrder && salesLine.mcrSalesLine().SourceId)
6956 {
6957 salesLine.ItemId = InventTable::mcrValidateItemIdFromSourceId(itemId, salesLine.mcrSalesLine().SourceId)? itemId: '';
6958 }
6959 else
6960 {
6961 salesLine.ItemId = itemId;
6962 }
6963
6964 element.setItemBarcodeFieldsOnSalesLine();
6965
6966 boolean isDropShipment = SalesLine.mcrInventTable().DropShipment;
6967 if (isDropShipment)
6968 {
6969 element.defaultInventDimBasedOnDirectDeliveryWarehouse(isDropShipment);
6970 }
6971
6972 super();
6973
6974 if (TaxIntegrationUtils::isTaxInformationEnabled())
6975 {
6976 if (salesLine.orig().ItemId != '')
6977 {
6978 TransTaxInformation transTaxInformationLocal = TransTaxInformationHelper::findOrCreateTransTaxInformationByRecord(salesLine);
6979 if (transTaxInformationLocal)
6980 {
6981 ttsbegin;
6982 transTaxInformationLocal.selectForUpdate(true);
6983 TransTaxInformationHelper::initFromInventItem(transTaxInformationLocal, salesLine.ItemId, CustTable::find(salesTable.CustAccount));
6984 transTaxInformationLocal.update();
6985 ttscommit;
6986 }
6987 }
6988 }
6989
6990 // <GIN>
6991 if (isIndiaIndirectTaxParameterMarked)
6992 {
6993 if (SalesTable::find(salesLine.SalesId).CustomsExportOrder_IN == NoYes::Yes)
6994 {
6995 //MRP defaulted from item is converted using Customs exchange rate for Export orders.
6996 salesLine_IN.MaximumRetailPrice = CurrencyHelper_IN::customsCurAmount_IN(salesLine_IN.CustomsMaxRetailPrice, salesTable.CurrencyCode, Direction_IN::Export, DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone()), false);
6997 }
6998 }
6999 if (TaxParameters::isCustomsEnable_IN()
7000 && salesTable.CustomsExportOrder_IN
7001 && TaxParameters::find().EximIncentiveSchemes_IN)
7002 {
7003 eximSalesLine_IN.EximProductGroupTable = InventTable::find(salesLine.ItemId).EximProductGroupTable_IN;
7004 element.enableFieldsActive_IN();
7005 }
7006 if (TaxParameters::checkTaxParameters_IN())
7007 {
7008 salesLine_IN.assessableValue(salesLine);
7009 }
7010 if (TaxParameters::checkTaxParameters_IN() || TaxWithholdParameters_IN::checkTaxParameters())
7011 {
7012 salesLine_IN_ds.refresh();
7013 }
7014
7015 // </GIN>
7016
7017 salesLine_ds.refreshDDC();
7018
7019 salesLine_DS.cacheCalculateMethod(tableMethodStr(SalesLine,itemName));
7020 if (isConfigurationkeyEnabled(configurationKeyNum(PDS)))
7021 {
7022 salesLine_ds.cacheCalculateMethod(tableMethodStr(SalesLine,pdsCWUnitId));
7023 }
7024
7025 // <GBR>
7026 if (BrazilParameters::isEnabled())
7027 {
7028 salesLine.setCFOP_BR();
7029
7030 if (salesLine.inventTable().ItemType != ItemType::Service)
7031 {
7032 salesLine.LedgerDimension = SalesPurchOperationType_BR::find(salesTable_BR.SalesPurchOperationType_BR).LedgerDimension;
7033 }
7034
7035 salesLine_ds.refresh();
7036
7037 salesLine_BR_DS.enableDataSourceFields_BR();
7038 }
7039 // </GBR>
7040
7041 if (EInvoiceParameters_MX::isElectronicInvoiceEnabled() || EInvoiceCFDIParameters_MX::isElectronicInvoiceEnabled())
7042 {
7043 salesLine.satProductCode_MX = salesLine.inventTable().satCodeId_MX;
7044 salesLine.satUnitCode_MX = UnitOfMeasure_W::findByUnitOfMeasure(UnitOfMeasure::findBySymbol(salesLine.SalesUnit).RecId).satCodeId_MX;
7045 salesLine.SATCustomUnitOfMeasure_MX = UnitOfMeasure_W::findByUnitOfMeasure(UnitOfMeasure::findBySymbol(salesLine.SalesUnit).RecId).SATCustomUnitOfMeasure;
7046 salesLine.SATTariffFraction_MX = salesLine.inventTable().SATTariffFraction_MX;
7047 salesLine.SATCustomsQty_MX = salesLine.SalesQty;
7048 }
7049
7050
7051 if (mcrCallCenterEnabled)
7052 {
7053 element.mcrDisplayItemMessage();
7054 MCRSalesLine_ds.giftCardPolicyChanged();
7055 element.mcrSetLineControls();
7056 }
7057
7058 if (productFromLookup) // if there was product selected from the product lookup
7059 {
7060 element.updateProductDimensions(InventDim::find(productFromLookup.InventDimId));
7061 productFromLookup = null;
7062 }
7063
7064 // set original price when item is entered or changed
7065 if (mcrCallCenterEnabled && mcrCallCenterOrder && enableOrderPriceControl)
7066 {
7067 retailSalesLine.OriginalPrice = salesLine.SalesPrice;
7068 }
7069 }
7070
7071 }
7072
7073 [DataField]
7074 class ItemRouteId
7075 {
7076 public void lookup(FormControl _formControl, str _filterStr)
7077 {
7078 InventTable::lookupRouteId(_formControl, salesLine.ItemId, inventDim);
7079 }
7080
7081 }
7082
7083 [DataField]
7084 class LineAmount
7085 {
7086 public boolean validate()
7087 {
7088 boolean ret;
7089
7090 ret = super();
7091
7092 if (ret
7093 && mcrCallCenterEnabled
7094 && enableOrderPriceControl)
7095 {
7096 ret = salesLine_ds.mcrGetOverrideResponse(fieldNum(SalesLine, LineAmount),
7097 salesLine.LineAmount,
7098 fieldNum(MCRPriceOverrideMarkUpGroup,CostMarkUpPercent));
7099 }
7100
7101 return ret;
7102 }
7103
7104 void modified()
7105 {
7106 super();
7107
7108 element.mcrRefreshMarginAlert();
7109
7110 salesLine_ds.active();
7111 }
7112
7113 }
7114
7115 [DataField]
7116 class LineDisc
7117 {
7118 public boolean validate()
7119 {
7120 boolean ret;
7121
7122 ret = super();
7123
7124 if (ret
7125 && mcrCallCenterEnabled
7126 && enableOrderPriceControl)
7127 {
7128 ret = salesLine_ds.mcrGetOverrideResponse(fieldNum(SalesLine, LineDisc),
7129 salesLine.LineDisc,
7130 fieldNum(MCRPriceOverrideMarkUpGroup, CostMarkUpPercent));
7131 }
7132
7133 return ret;
7134 }
7135
7136 public void modified()
7137 {
7138 super();
7139
7140 element.mcrRefreshMarginAlert();
7141 }
7142
7143 }
7144
7145 [DataField]
7146 class LinePercent
7147 {
7148 public boolean validate()
7149 {
7150 boolean ret;
7151
7152 ret = super();
7153
7154 if (ret
7155 && mcrCallCenterEnabled
7156 && enableOrderPriceControl)
7157 {
7158 ret = salesLine_ds.mcrGetOverrideResponse(fieldNum(SalesLine, LinePercent),
7159 salesLine.LinePercent,
7160 fieldNum(MCRPriceOverrideMarkUpGroup,DiscPercentOverride));
7161 }
7162
7163 return ret;
7164 }
7165
7166 public void modified()
7167 {
7168 super();
7169
7170 element.mcrRefreshMarginAlert();
7171 }
7172
7173 }
7174
7175 [DataField]
7176 class MultiLnDisc
7177 {
7178 public boolean validate()
7179 {
7180 boolean ret;
7181
7182 ret = super();
7183
7184 if (ret
7185 && mcrCallCenterEnabled
7186 && enableOrderPriceControl)
7187 {
7188 ret = salesLine_ds.mcrGetOverrideResponse(fieldNum(SalesLine, MultiLnDisc),
7189 salesLine.MultiLnDisc,
7190 fieldNum(MCRPriceOverrideMarkUpGroup,CostMarkUpPercent));
7191 }
7192
7193 return ret;
7194 }
7195
7196 public void modified()
7197 {
7198 super();
7199
7200 if (mcrCallCenterEnabled && enableOrderPriceControl)
7201 {
7202 salesLine_ds.mcrSetWorkflowApprovalStatus();
7203 }
7204 }
7205
7206 }
7207
7208 [DataField]
7209 class MultiLnPercent
7210 {
7211 public boolean validate()
7212 {
7213 boolean ret;
7214
7215 ret = super();
7216
7217 if (ret
7218 && mcrCallCenterEnabled
7219 && enableOrderPriceControl)
7220 {
7221 ret = salesLine_ds.mcrGetOverrideResponse(fieldNum(SalesLine, MultiLnPercent),
7222 salesLine.MultiLnPercent,
7223 fieldNum(MCRPriceOverrideMarkUpGroup,DiscPercentOverride));
7224 }
7225
7226 return ret;
7227 }
7228
7229 public void modified()
7230 {
7231 super();
7232
7233 if (mcrCallCenterEnabled && enableOrderPriceControl)
7234 {
7235 salesLine_ds.mcrSetWorkflowApprovalStatus();
7236 }
7237 }
7238
7239 }
7240
7241 [DataField]
7242 class Name
7243 {
7244 public void modified()
7245 {
7246 super();
7247 // Do not default Name from category when modified.
7248 keepName = true;
7249 }
7250
7251 }
7252
7253 [DataField]
7254 class PdsCWQty
7255 {
7256 public void modified()
7257 {
7258 salesLine.InventDimId = InventDim::findOrCreate(inventDim).InventDimId;
7259
7260 super();
7261
7262 element.mcrRefreshMarginAlert();
7263 salesLine.modifyWMSLocation(inventDim, false, InventDirection::Issue, InventDirection::Issue);
7264
7265 element.checkCreditNoteLine();
7266 interCompanyIsPriceDiscSearchNeeded = salesLine.RecId;
7267 salesLine_ds.refresh();
7268 }
7269
7270 }
7271
7272 [DataField]
7273 class PriceUnit
7274 {
7275 public boolean validate()
7276 {
7277 boolean ret;
7278
7279 ret = super();
7280
7281 if (ret
7282 && mcrCallCenterEnabled
7283 && enableOrderPriceControl)
7284 {
7285 ret = salesLine_ds.mcrGetOverrideResponse(fieldNum(SalesLine, PriceUnit),
7286 salesLine.PriceUnit,
7287 fieldNum(MCRPriceOverrideMarkUpGroup,CostMarkUpPercent));
7288 }
7289
7290 return ret;
7291 }
7292
7293 void modified()
7294 {
7295 super();
7296
7297 element.mcrRefreshMarginAlert();
7298
7299 if (mcrCallCenterEnabled && enableOrderPriceControl)
7300 {
7301 salesLine_ds.mcrSetWorkflowApprovalStatus();
7302 }
7303
7304 salesLine_ds.refresh();
7305 }
7306
7307 }
7308
7309 [DataField]
7310 class ProjTransId
7311 {
7312 public void jumpRef()
7313 {
7314 ProjItemTrans::jumpRefTransId(salesLine, element);
7315 }
7316
7317 }
7318
7319 [DataField]
7320 class Reservation
7321 {
7322 public void modified()
7323 {
7324 super();
7325
7326 if (#PdsSameLotEnabled
7327 && salesLine.Reservation == ItemReservation::Automatic)
7328 {
7329 // trigger a change on the quantity, so batch reservation can be called
7330 salesTable_ds.object(fieldNum(SalesLine, SalesQty)).modified();
7331 }
7332
7333 //salesTableForm.pdsSetLineAccessKeepSalesQty(salesLine);
7334 }
7335
7336 }
7337
7338 [DataField]
7339 class RetailVariantId
7340 {
7341 /// <summary>
7342 /// Jump Reference
7343 /// </summary>
7344 public void jumpRef()
7345 {
7346 Args args = new Args();
7347
7348 args.caller(element);
7349 args.record(InventTable::find(salesLine.ItemId));
7350 args.lookupRecord(EcoResDistinctProductVariant::find(InventDimCombination::findVariantId(salesLine.RetailVariantId).DistinctProductVariant));
7351
7352 new MenuFunction(menuitemDisplayStr(EcoResProductVariantsAction), MenuItemType::Display).run(args);
7353 }
7354
7355 /// <summary>
7356 /// Retail Variant ID - Modified
7357 /// </summary>
7358 public void modified()
7359 {
7360 super();
7361
7362 InventDim variantInventDim = InventDimCombination::findVariantId(salesLine.RetailVariantId).inventDim();
7363 if (variantInventDim)
7364 {
7365 element.updateProductDimensions(variantInventDim);
7366 }
7367 }
7368
7369 /// <summary>
7370 /// RetailVariantId - Lookup
7371 /// </summary>
7372 /// <param name="_formControl">
7373 /// Form String Control
7374 /// </param>
7375 /// <param name="_filterStr">
7376 /// Filter String
7377 /// </param>
7378 public void lookup(FormControl _formControl, str _filterStr)
7379 {
7380 // super(_formControl, _filterStr);
7381
7382 FormRun formRun = classfactory.formRunClass(new Args(formStr(RetailVariantLookup)));
7383 FormStringControl formControl = _formControl;
7384
7385 formRun.args().parm(salesLine.ItemId);
7386 formRun.args().caller(_formControl);
7387 formRun.init();
7388
7389 formRun.run();
7390 formControl.performFormLookup(formRun);
7391 }
7392
7393 }
7394
7395 [DataField]
7396 class SalesCategory
7397 {
7398 public Common resolveReference(FormReferenceControl _formReferenceControl)
7399 {
7400 return EcoResCategory::resolveCategoryHierarchyRole(
7401 _formReferenceControl,
7402 EcoResCategoryNamedHierarchyRole::Sales);
7403 }
7404
7405 public Common lookupReference(FormReferenceControl _formReferenceControl)
7406 {
7407 return EcoResCategory::lookupCategoryHierarchyRole(
7408 _formReferenceControl,
7409 EcoResCategoryNamedHierarchyRole::Sales);
7410 }
7411
7412 public void modified()
7413 {
7414 SalesCategory salesCategory;
7415 ItemFreeTxt name;
7416
7417 if (keepName)
7418 {
7419 name = salesLine.Name;
7420 }
7421
7422 // Reset line, but keep category
7423 salesCategory = salesLine.SalesCategory;
7424
7425 salesTableForm.resetSalesLine(salesLine);
7426
7427 salesLine.SalesCategory = salesCategory;
7428
7429 super();
7430
7431 // Name is defaulted from category in super(). So we revert to saved value it if needed.
7432 if (keepName)
7433 {
7434 salesLine.Name = name;
7435 }
7436
7437 // Enabled/disable fields
7438 salesLine_ds.changedStockedStatus(true);
7439
7440 if (salesLine.isCategoryBased())
7441 {
7442 mcrSalesLineDropShipment_ds.allowEdit(false);
7443
7444 if (salesTable.MatchingAgreement)
7445 {
7446 salesLine.salesPurchLineInterface().autoMatchAgreementLine(salesTable.MatchingAgreement);
7447 }
7448
7449 if (salesLineForeignTradeCategory.SalesLineDataAreaId == '')
7450 {
7451 //Only create record if no one exists
7452 salesLineForeignTradeCategory_ds.allowCreate(true);
7453 salesLineForeignTradeCategory_ds.create();
7454 salesLineForeignTradeCategory_ds.allowEdit(true);
7455 salesLineForeignTradeCategory_ds.allowCreate(false);
7456 }
7457 }
7458 else
7459 {
7460 mcrSalesLineDropShipment_ds.allowEdit(true);
7461 salesLineForeignTradeCategory.clearFormFields();
7462 salesLineForeignTradeCategory_ds.allowEdit(false);
7463 salesLineForeignTradeCategory_ds.refresh();
7464 }
7465 }
7466
7467 }
7468
7469 [DataField]
7470 class SalesMarkup
7471 {
7472 public boolean validate()
7473 {
7474 boolean ret;
7475
7476 ret = super();
7477
7478 if (ret
7479 && mcrCallCenterEnabled
7480 && enableOrderPriceControl)
7481 {
7482 ret = salesLine_ds.mcrGetOverrideResponse(fieldNum(SalesLine, SalesMarkup),
7483 salesLine.SalesMarkup,
7484 fieldNum(MCRPriceOverrideMarkUpGroup,CostMarkUpPercent));
7485 }
7486
7487 return ret;
7488 }
7489
7490 public void modified()
7491 {
7492 super();
7493
7494 if (mcrCallCenterEnabled && enableOrderPriceControl)
7495 {
7496 salesLine_ds.mcrSetWorkflowApprovalStatus();
7497 }
7498 }
7499
7500 }
7501
7502 [DataField]
7503 class SalesPrice
7504 {
7505 public boolean validate()
7506 {
7507 boolean ret;
7508 DiscAmount originalLineDisc;
7509
7510 ret = super();
7511
7512 if (ret
7513 && mcrCallCenterEnabled
7514 && enableOrderPriceControl
7515 && RetailParameters::find().GiftcardItem != salesLine.ItemId)
7516 {
7517 if (salesLine.mcrInventTable().AllowPriceAdjust == NoYes::No)
7518 {
7519 ret = checkFailed("@MCR34339");
7520 }
7521 else
7522 {
7523 originalLineDisc = salesLine.lineDisc;
7524 salesLine.lineDisc = salesLine.salesPurchLineInterface().getRetailLineDisc();
7525
7526 ret = salesLine_ds.mcrGetOverrideResponse(fieldNum(SalesLine, SalesPrice),
7527 salesLine.SalesPrice,
7528 fieldNum(MCRPriceOverrideMarkUpGroup,CostMarkUpPercent));
7529
7530 salesLine.lineDisc = originalLineDisc;
7531 }
7532 }
7533
7534 return ret;
7535 }
7536
7537 public void modified()
7538 {
7539 super();
7540
7541 if (RetailPricingEngine::useRetailPricingEngineForSalesOrder(salesTable.SalesId))
7542 {
7543 salesLine.setPriceDisc(inventDim, true);
7544 }
7545
7546 element.mcrRefreshMarginAlert();
7547
7548 if (mcrCallCenterEnabled && enableOrderPriceControl)
7549 {
7550 salesLine_ds.mcrSetWorkflowApprovalStatus();
7551
7552 if (!retailSalesLine.OriginalPrice)
7553 {
7554 if (salesLine.orig().SalesPrice)
7555 {
7556 retailSalesLine.OriginalPrice = salesLine.orig().SalesPrice;
7557 }
7558 else
7559 {
7560 retailSalesLine.OriginalPrice = salesLine.SalesPrice;
7561 }
7562 }
7563
7564 if (retailSalesLine.OriginalPrice != salesLine.SalesPrice)
7565 {
7566 retailSalesLine.IsPriceOverridden = NoYes::Yes;
7567 }
7568 else
7569 {
7570 retailSalesLine.IsPriceOverridden = NoYes::No;
7571 }
7572 }
7573
7574 salesLine_ds.refresh();
7575 }
7576
7577 }
7578
7579 [DataField]
7580 class SalesQty
7581 {
7582 void modified()
7583 {
7584 InventQty pickedQty;
7585 InventQty qtyOrdered;
7586
7587 if (salesLine.SalesQty > 0 && salesLine.type().mustSalesQtyBeNegative())
7588 {
7589 error("@SYS98119");
7590 }
7591
7592 if (mcrCallCenterEnabled)
7593 {
7594 // If the user tries to change the quantity below what has already been picked
7595 // for the line, an error will be issued.
7596 pickedQty = salesLine.mcrPickedLineQuantity();
7597 if (pickedQty != 0)
7598 {
7599 qtyOrdered = EcoResProductUnitConverter::convertGivenUnitSymbolsForReleasedProduct(
7600 salesLine.ItemId,
7601 salesLine.InventDimId,
7602 salesLine.SalesQty,
7603 salesLine.SalesUnit,
7604 salesLine.inventTable().inventTableModuleInvent().UnitId,
7605 NoYes::Yes);
7606
7607 if (abs(qtyOrdered) < abs(pickedQty))
7608 {
7609 throw error("@MCR12251");
7610 }
7611 }
7612 }
7613
7614 salesLine.InventDimId = InventDim::findOrCreate(inventDim).InventDimId;
7615
7616 super();
7617
7618 element.mcrRefreshMarginAlert();
7619 salesLine.modifyWMSLocation(inventDim, false, InventDirection::Issue, InventDirection::Issue);
7620
7621 element.checkCreditNoteLine();
7622
7623 interCompanyIsPriceDiscSearchNeeded = salesLine.RecId;
7624
7625 salesLine_ds.refresh();
7626
7627 // <GIN>
7628 if (TaxParameters::isCustomsEnable_IN())
7629 {
7630 if (TaxParameters::find().EximIncentiveSchemes_IN && salesLine.SalesQty < 0)
7631 {
7632 eximSalesLine_IN.ApplyDEPB = NoYes::No;
7633 eximSalesLine_IN.MarketValue = 0.00;
7634 eximSalesLine_IN.dbkCenvatStatus = EximDBKCenvatStatus_IN::None;
7635 eximSalesLine_IN.dbkRateType = EximDBKRateType_IN::AllIndustryRate;
7636 eximSalesLine_IN.dbkPercent = 100;
7637 eximSalesLine_IN.EximIncentiveSchemeGroup = 0;
7638 eximSalesLine_IN.EximPorts = 0;
7639 eximSalesLine_IN.EximProductGroupTable = 0;
7640 }
7641
7642 if (TaxParameters::find().EximIncentiveSchemes_IN && salesLine.SalesQty > 0)
7643 {
7644 eximSalesLine_IN.EximProductGroupTable = InventTable::find(salesLine.ItemId).EximProductGroupTable_IN;
7645 }
7646
7647 element.setEximFieldsAccess_IN();
7648 }
7649 // </GIN>
7650
7651 if (RetailPricingEngine::useRetailPricingEngineForSalesOrder(salesTable.SalesId))
7652 {
7653 salesLine.setPriceDisc(inventDim);
7654 }
7655
7656 salesLine_ds.refreshDDC();
7657
7658 // If the quantity is modified need to update the related children.
7659 // But only if none have been created yet.
7660 if (mcrSalesLine.LineType == MCRLineType::ContinuityParent
7661 && mcrCallCenterEnabled)
7662 {
7663 salesLine.mcrUpdateContCustLines();
7664 }
7665 }
7666
7667 public boolean validate()
7668 {
7669 boolean ret;
7670
7671 // Prevent unnecessary failure when user enters a positive qty
7672 // for a return order.
7673 if (salesTable.SalesType == SalesType::ReturnItem)
7674 {
7675 salesLine.SalesQty = (salesLine.SalesQty > 0) ? -salesLine.SalesQty : salesLine.SalesQty;
7676 }
7677
7678 ret = super();
7679
7680 return ret;
7681 }
7682
7683 }
7684
7685 [DataField]
7686 class SalesUnit
7687 {
7688 void modified()
7689 {
7690 salesLine.InventDimId = InventDim::findOrCreate(inventDim).InventDimId;
7691
7692 super();
7693
7694 if (EcoResProductUnitConverter::hasRequiredProductDimensionsForUnitConversion(salesLine.ItemId, salesLine.inventDim()))
7695 {
7696 salesLine.setPriceDisc(inventDim);
7697 }
7698
7699 interCompanyIsPriceDiscSearchNeeded = salesLine.RecId;
7700 salesLine.calcPackingUnitQty(inventDim);
7701
7702 if (EInvoiceParameters_MX::isElectronicInvoiceEnabled() || EInvoiceCFDIParameters_MX::isElectronicInvoiceEnabled())
7703 {
7704 salesLine.satUnitCode_MX = UnitOfMeasure_W::findByUnitOfMeasure(UnitOfMeasure::findBySymbol(salesLine.SalesUnit).RecId).satCodeId_MX;
7705 salesLine.SATCustomUnitOfMeasure_MX = UnitOfMeasure_W::findByUnitOfMeasure(UnitOfMeasure::findBySymbol(salesLine.SalesUnit).RecId).SATCustomUnitOfMeasure;
7706 salesLine.SATCustomsQty_MX = salesLine.SalesQty;
7707 }
7708
7709 salesLine_ds.refresh();
7710 }
7711
7712 public boolean validate()
7713 {
7714 boolean ret;
7715
7716 ret = super();
7717
7718 if (ret && salesLine.RecId && !salesLine.isAgreementLinkValid())
7719 {
7720 ret = salesLine.unLinkAgreementLinePrompt(fieldNum(SalesLine,SalesUnit));
7721 }
7722
7723 return ret;
7724 }
7725
7726 }
7727
7728 }
7729
7730 [DataSource]
7731 class SalesLineForeignTradeCategory
7732 {
7733 public int active()
7734 {
7735 int ret;
7736 boolean allowEditLine;
7737
7738 ret = super();
7739
7740 if (salesLine.isCategoryBased())
7741 {
7742 allowEditLine = salesTableForm.editLineAllowed();
7743 salesLineForeignTradeCategory_ds.allowEdit(allowEditLine);
7744 }
7745 else
7746 {
7747 salesLineForeignTradeCategory_ds.allowEdit(false);
7748 }
7749
7750 return ret;
7751 }
7752
7753 public boolean validateWrite()
7754 {
7755 boolean ret = true;
7756
7757 if (salesLine.RecId && salesLine.isCategoryBased())
7758 {
7759 ret = super();
7760 }
7761
7762 return ret;
7763 }
7764
7765 public void write()
7766 {
7767 if (salesLine.RecId && salesLine.isCategoryBased())
7768 {
7769 super();
7770 }
7771 }
7772
7773 public void create(boolean _append = false)
7774 {
7775 if (salesLine.isCategoryBased())
7776 {
7777 super(_append);
7778 }
7779 }
7780
7781 }
7782
7783 [DataSource]
7784 class InventDim
7785 {
7786 display FiscalEstablishmentId_BR FiscalEstablishment()
7787 {
7788 return inventDim.inventSite().fiscalEstablishment().FiscalEstablishmentId;
7789 }
7790
7791 public void write()
7792 {
7793 // super();
7794 }
7795
7796 void initValue()
7797 {
7798 inventDim.data(InventDim::find(salesLine.InventDimId));
7799
7800 super();
7801 }
7802
7803 internal void modifyCustomInventDimension(FieldId _fieldId)
7804 {
7805 if (InventDim::isFieldIdProductDimension(_fieldId))
7806 {
7807 element.modifyInventDimField(_fieldId);
7808 element.performUpdatePostProductDimensionChange();
7809 }
7810 else if (InventDim::isFieldIdTrackingDimension(_fieldId))
7811 {
7812 salesLine.modifyInventDim(inventDim, _fieldId, !salesLine.MatchingAgreementLine);
7813
7814 if (salesLine.DeliveryDateControlType)
7815 {
7816 SalesCalcAvailableDlvDates salesCalcAvailableDlvDates = SalesCalcAvailableDlvDates::newCommonSalesDlvDateType(salesLine, 0, inventDim);
7817 salesCalcAvailableDlvDates.modifiedFieldBeforeInsert(salesLine);
7818 }
7819
7820 element.mcrRefreshMarginAlert();
7821 }
7822 }
7823
7824 [DataField]
7825 class configId
7826 {
7827 public void modified()
7828 {
7829 super();
7830
7831 element.modifyInventDimField(fieldNum(InventDim, ConfigId));
7832 element.performUpdatePostProductDimensionChange();
7833 }
7834
7835 public void lookup(FormControl _formControl, str _filterStr)
7836 {
7837 if (!EcoResProductMasterConfigurationMgr::configure(_formControl,
7838 salesLine.ItemId,
7839 InventDim::findOrCreate(inventDim).InventDimId,
7840 salesLine.deliveryDate(),
7841 salesLine.ItemBOMId,
7842 salesLine.QtyOrdered))
7843 {
7844 super(_formControl, _filterStr);
7845 }
7846 }
7847
7848 public boolean validate()
7849 {
7850 boolean ret;
7851
7852 ret = super();
7853
7854 if (ret)
7855 {
7856 ret = salesLine.validateModifyInventDim(inventDim,fieldNum(InventDim,ConfigId));
7857 }
7858
7859 return ret;
7860 }
7861
7862 }
7863
7864 [DataField]
7865 class inventBatchId
7866 {
7867 public void modified()
7868 {
7869 SalesCalcAvailableDlvDates salesCalcAvailableDlvDates;
7870
7871 super();
7872
7873 salesLine.modifyInventDim(inventDim, fieldNum(InventDim,InventBatchId), !salesLine.MatchingAgreementLine);
7874
7875 if (salesLine.DeliveryDateControlType)
7876 {
7877 salesCalcAvailableDlvDates = SalesCalcAvailableDlvDates::newCommonSalesDlvDateType(salesLine,0,inventDim);
7878 salesCalcAvailableDlvDates.modifiedFieldBeforeInsert(salesLine);
7879 }
7880
7881 element.mcrRefreshMarginAlert();
7882 }
7883
7884 public boolean validate()
7885 {
7886 boolean ret;
7887
7888 ret = super();
7889
7890 if (ret)
7891 {
7892 ret = salesLine.validateModifyInventDim(inventDim,fieldNum(InventDim,InventBatchId));
7893 }
7894
7895 return ret;
7896 }
7897
7898 }
7899
7900 [DataField]
7901 class InventColorId
7902 {
7903 public void modified()
7904 {
7905 super();
7906
7907 element.modifyInventDimField(fieldNum(InventDim, InventColorId));
7908 element.performUpdatePostProductDimensionChange();
7909 }
7910
7911 public boolean validate()
7912 {
7913 boolean ret;
7914
7915 ret = super();
7916
7917 if (ret)
7918 {
7919 ret = salesLine.validateModifyInventDim(inventDim,fieldNum(InventDim,InventColorId));
7920 }
7921
7922 return ret;
7923 }
7924
7925 }
7926
7927 [DataField]
7928 class InventDimension1
7929 {
7930 public void modified()
7931 {
7932 super();
7933
7934 //InventDim_ds.modifyCustomInventDimension(fieldnum(InventDim, InventDimension1));
7935 }
7936
7937 public boolean validate()
7938 {
7939 return super() && salesLine.validateModifyInventDim(inventDim, fieldNum(InventDim, InventDimension1));
7940 }
7941
7942 }
7943
7944 [DataField]
7945 class InventDimension10
7946 {
7947 public void modified()
7948 {
7949 super();
7950
7951 //InventDim_ds.modifyCustomInventDimension(fieldNum(InventDim, InventDimension10));
7952 }
7953
7954 public boolean validate()
7955 {
7956 return super() && salesLine.validateModifyInventDim(inventDim, fieldNum(InventDim, InventDimension10));
7957 }
7958
7959 }
7960
7961 [DataField]
7962 class InventDimension2
7963 {
7964 public void modified()
7965 {
7966 super();
7967
7968 //InventDim_ds.modifyCustomInventDimension(fieldNum(InventDim, InventDimension2));
7969 }
7970
7971 public boolean validate()
7972 {
7973 return super() && salesLine.validateModifyInventDim(inventDim, fieldNum(InventDim, InventDimension2));
7974 }
7975
7976 }
7977
7978 [DataField]
7979 class InventDimension3
7980 {
7981 public void modified()
7982 {
7983 super();
7984
7985 //InventDim_ds.modifyCustomInventDimension(fieldNum(InventDim, InventDimension3));
7986 }
7987
7988 public boolean validate()
7989 {
7990 return super() && salesLine.validateModifyInventDim(inventDim, fieldNum(InventDim, InventDimension3));
7991 }
7992
7993 }
7994
7995 [DataField]
7996 class InventDimension4
7997 {
7998 public void modified()
7999 {
8000 super();
8001
8002 //InventDim_ds.modifyCustomInventDimension(fieldNum(InventDim, InventDimension4));
8003 }
8004
8005 public boolean validate()
8006 {
8007 return super() && salesLine.validateModifyInventDim(inventDim, fieldNum(InventDim, InventDimension4));
8008 }
8009
8010 }
8011
8012 [DataField]
8013 class InventDimension5
8014 {
8015 public void modified()
8016 {
8017 super();
8018
8019 //InventDim_ds.modifyCustomInventDimension(fieldNum(InventDim, InventDimension5));
8020 }
8021
8022 public boolean validate()
8023 {
8024 return super() && salesLine.validateModifyInventDim(inventDim, fieldNum(InventDim, InventDimension5));
8025 }
8026
8027 }
8028
8029 [DataField]
8030 class InventDimension6
8031 {
8032 public void modified()
8033 {
8034 super();
8035
8036 //InventDim_ds.modifyCustomInventDimension(fieldNum(InventDim, InventDimension6));
8037 }
8038
8039 public boolean validate()
8040 {
8041 return super() && salesLine.validateModifyInventDim(inventDim, fieldNum(InventDim, InventDimension6));
8042 }
8043
8044 }
8045
8046 [DataField]
8047 class InventDimension7
8048 {
8049 public void modified()
8050 {
8051 super();
8052
8053 //InventDim_ds.modifyCustomInventDimension(fieldNum(InventDim, InventDimension7));
8054 }
8055
8056 public boolean validate()
8057 {
8058 return super() && salesLine.validateModifyInventDim(inventDim, fieldNum(InventDim, InventDimension7));
8059 }
8060
8061 }
8062
8063 [DataField]
8064 class InventDimension8
8065 {
8066 public void modified()
8067 {
8068 super();
8069
8070 //InventDim_ds.modifyCustomInventDimension(fieldNum(InventDim, InventDimension8));
8071 }
8072
8073 public boolean validate()
8074 {
8075 return super() && salesLine.validateModifyInventDim(inventDim, fieldNum(InventDim, InventDimension8));
8076 }
8077
8078 }
8079
8080 [DataField]
8081 class InventDimension9
8082 {
8083 public void modified()
8084 {
8085 super();
8086
8087 //InventDim_ds.modifyCustomInventDimension(fieldNum(InventDim, InventDimension9));
8088 }
8089
8090 public boolean validate()
8091 {
8092 return super() && salesLine.validateModifyInventDim(inventDim, fieldNum(InventDim, InventDimension9));
8093 }
8094
8095 }
8096
8097 [DataField]
8098 class InventGtdId_RU
8099 {
8100 public boolean validate()
8101 {
8102 boolean ret;
8103
8104 ret = super();
8105
8106 if (ret)
8107 {
8108 ret = salesLine.validateModifyInventDim(inventDim,
8109 fieldNum(InventDim, InventGtdId_RU));
8110 }
8111
8112 return ret;
8113 }
8114
8115 public void modified()
8116 {
8117 super();
8118
8119 salesLine.modifyInventDim(inventDim,
8120 fieldNum(InventDim, InventGtdId_RU),
8121 InventTable::itemProductDimensionGroup(salesLine.ItemId));
8122
8123 if (salesLine.DeliveryDateControlType)
8124 {
8125 SalesCalcAvailableDlvDates::newCommonSalesDlvDateType(salesLine, 0, inventDim).modifiedField(salesLine, false);
8126 }
8127
8128 element.mcrRefreshMarginAlert();
8129 }
8130
8131 }
8132
8133 [DataField]
8134 class InventLocationId
8135 {
8136 public void modified()
8137 {
8138 SalesCalcAvailableDlvDates salesCalcAvailableDlvDates;
8139
8140 super();
8141
8142 salesLine.modifyInventDim(inventDim, fieldNum(InventDim,InventLocationId), salesLine.canPriceBeReset());
8143
8144 if (!salesLine.RecId && salesLine.DeliveryDateControlType != SalesDeliveryDateControlType::None)
8145 {
8146 salesCalcAvailableDlvDates = SalesCalcAvailableDlvDates::newCommonSalesDlvDateType(salesLine,0,inventDim);
8147 salesCalcAvailableDlvDates.modifiedFieldBeforeInsert(salesLine);
8148
8149 salesLine.ConfirmedDlv = salesLine.ShippingDateConfirmed ? salesLine.ShippingDateConfirmed : salesLine.ShippingDateRequested;
8150 }
8151
8152 // Update the fulfillment line status if the order is rejected
8153 if (retailSalesLine && retailSalesLine.FulfillmentStatus == RetailFulfillmentLineStatus::Rejected
8154 && isConfigurationkeyEnabled(configurationKeyNum(Retail)))
8155 {
8156 RetailTransactionServiceFulfillment::updateFulfillmentStatusFromEditSalesLine(salesLine, true);
8157 }
8158
8159 if (salesLine_ds && salesLine)
8160 {
8161 salesLine_ds.refresh();
8162
8163 retailSalesLine_ds.reread();
8164 retailSalesLine_ds.refresh();
8165 }
8166
8167 if (salesLine_ds &&
8168 (TaxParameters::checkTaxParameters_IN() || TaxWithholdParameters_IN::checkTaxParameters()))
8169 {
8170 salesLine_IN_ds.refresh();
8171 }
8172
8173 element.mcrRefreshMarginAlert();
8174
8175 if (TaxIntegrationUtils::isTaxInformationEnabled())
8176 {
8177 TransTaxInformationHelper::newHelper().UpdateCompanyLocationFromTransTable(salesLine, LogisticsPostalAddress::findByLocation(TaxLogisticsLocationControllerHelper_IN::getDefaultLogisticsLocation(inventDim.InventLocationId, inventDim.InventSiteId)).RecId);
8178 }
8179 // </GIN>
8180
8181 element.updateSalesLineDeliveryAddress();
8182
8183 }
8184
8185 public boolean validate()
8186 {
8187 boolean ret;
8188
8189 ret = super();
8190
8191 if (ret)
8192 {
8193 ret = salesLine.validateModifyInventDim(inventDim,fieldNum(InventDim,InventLocationId));
8194 }
8195
8196 return ret;
8197 }
8198
8199 }
8200
8201 [DataField]
8202 class InventOwnerId_RU
8203 {
8204 public void modified()
8205 {
8206 super();
8207
8208 salesLine.modifyInventDim(inventDim,
8209 fieldNum(InventDim, InventOwnerId_RU));
8210
8211 if (salesLine.DeliveryDateControlType)
8212 {
8213 SalesCalcAvailableDlvDates::newCommonSalesDlvDateType(salesLine, 0, inventDim).modifiedField(salesLine, false);
8214 }
8215
8216 element.mcrRefreshMarginAlert();
8217 }
8218
8219 public boolean validate()
8220 {
8221 boolean ret;
8222
8223 ret = super();
8224
8225 if (ret)
8226 {
8227 ret = salesLine.validateModifyInventDim(inventDim,
8228 fieldNum(InventDim, InventOwnerId_RU));
8229 }
8230
8231 return ret;
8232 }
8233
8234 }
8235
8236 [DataField]
8237 class InventProfileId_RU
8238 {
8239 public void modified()
8240 {
8241 super();
8242
8243 salesLine.modifyInventDim(inventDim,
8244 fieldNum(InventDim, InventProfileId_RU));
8245
8246 if (salesLine.DeliveryDateControlType)
8247 {
8248 SalesCalcAvailableDlvDates::newCommonSalesDlvDateType(salesLine, 0, inventDim).modifiedField(salesLine, false);
8249 }
8250
8251 element.mcrRefreshMarginAlert();
8252 }
8253
8254 public boolean validate()
8255 {
8256 boolean ret;
8257
8258 ret = super();
8259
8260 if (ret)
8261 {
8262 ret = salesLine.validateModifyInventDim(inventDim,
8263 fieldNum(InventDim, InventProfileId_RU));
8264 }
8265
8266 return ret;
8267 }
8268
8269 }
8270
8271 [DataField]
8272 class inventSerialId
8273 {
8274 public void modified()
8275 {
8276 SalesCalcAvailableDlvDates salesCalcAvailableDlvDates;
8277
8278 super();
8279
8280 salesLine.modifyInventDim(inventDim, fieldNum(InventDim,InventSerialId), !salesLine.MatchingAgreementLine);
8281
8282 if (salesLine.DeliveryDateControlType)
8283 {
8284 salesCalcAvailableDlvDates = SalesCalcAvailableDlvDates::newCommonSalesDlvDateType(salesLine,0,inventDim);
8285 salesCalcAvailableDlvDates.modifiedFieldBeforeInsert(salesLine);
8286 }
8287
8288 element.mcrRefreshMarginAlert();
8289 }
8290
8291 public boolean validate()
8292 {
8293 boolean ret;
8294
8295 ret = super();
8296
8297 if (ret)
8298 {
8299 ret = salesLine.validateModifyInventDim(inventDim,fieldNum(InventDim,InventSerialId));
8300 }
8301
8302 return ret;
8303 }
8304
8305 }
8306
8307 [DataField]
8308 class InventSiteId
8309 {
8310 public void modified()
8311 {
8312 SalesCalcAvailableDlvDates salesCalcAvailableDlvDates;
8313
8314 super();
8315
8316 element.modifyInventDimField(fieldNum(InventDim, InventSiteId));
8317
8318 if (!salesLine.RecId)
8319 {
8320 if (salesLine.DeliveryDateControlType != SalesDeliveryDateControlType::None)
8321 {
8322 salesCalcAvailableDlvDates = SalesCalcAvailableDlvDates::newCommonSalesDlvDateType(salesLine,0,inventDim);
8323 salesCalcAvailableDlvDates.modifiedFieldBeforeInsert(salesLine);
8324
8325 salesLine.ConfirmedDlv = salesLine.ShippingDateConfirmed ? salesLine.ShippingDateConfirmed : salesLine.ShippingDateRequested;
8326 }
8327 }
8328
8329 if (salesLine_ds && salesLine)
8330 {
8331 salesLine_ds.refresh();
8332 }
8333
8334 if (salesLine_ds &&
8335 (TaxParameters::checkTaxParameters_IN() || TaxWithholdParameters_IN::checkTaxParameters()))
8336 {
8337 salesLine_IN_ds.refresh();
8338 }
8339
8340 element.mcrRefreshMarginAlert();
8341
8342 if (TaxIntegrationUtils::isTaxInformationEnabled())
8343 {
8344 TransTaxInformationHelper::newHelper().UpdateCompanyLocationFromTransTable(salesLine, LogisticsPostalAddress::findByLocation(TaxLogisticsLocationControllerHelper_IN::getDefaultLogisticsLocation(inventDim.InventLocationId, inventDim.InventSiteId)).RecId);
8345 }
8346 }
8347
8348 public boolean validate()
8349 {
8350 boolean ret;
8351
8352 ret = super();
8353
8354 if (ret)
8355 {
8356 ret = salesLine.validateModifyInventDim(inventDim,fieldNum(InventDim,InventSiteId));
8357 }
8358
8359 return ret;
8360 }
8361
8362 }
8363
8364 [DataField]
8365 class InventSizeId
8366 {
8367 public void modified()
8368 {
8369 super();
8370
8371 element.modifyInventDimField(fieldNum(InventDim, InventSizeId));
8372 element.performUpdatePostProductDimensionChange();
8373 }
8374
8375 public boolean validate()
8376 {
8377 boolean ret;
8378
8379 ret = super();
8380
8381 if (ret)
8382 {
8383 ret = salesLine.validateModifyInventDim(inventDim,fieldNum(InventDim,InventSizeId));
8384 }
8385
8386 return ret;
8387 }
8388
8389 }
8390
8391 [DataField]
8392 class InventStatusId
8393 {
8394 public boolean validate()
8395 {
8396 boolean ret;
8397
8398 ret = super();
8399
8400 if (ret)
8401 {
8402 ret = salesLine.validateModifyInventDim(inventDim, fieldNum(InventDim, InventStatusId));
8403 }
8404
8405 return ret;
8406 }
8407
8408 public void modified()
8409 {
8410 SalesCalcAvailableDlvDates salesCalcAvailableDlvDates;
8411
8412 super();
8413
8414 salesLine.modifyInventDim(inventDim, fieldNum(InventDim, InventStatusId), !salesLine.MatchingAgreementLine);
8415
8416 if (salesLine.DeliveryDateControlType)
8417 {
8418 salesCalcAvailableDlvDates = SalesCalcAvailableDlvDates::newCommonSalesDlvDateType(salesLine, 0, inventDim);
8419 salesCalcAvailableDlvDates.modifiedFieldBeforeInsert(salesLine);
8420 }
8421
8422 element.mcrRefreshMarginAlert();
8423 }
8424
8425 public void lookup(FormControl _formControl, str _filterStr)
8426 {
8427 WHSInventStatus::lookupInventStatus(_formControl, NoYes::No);
8428 }
8429
8430 }
8431
8432 [DataField]
8433 class InventStyleId
8434 {
8435 public void modified()
8436 {
8437 super();
8438
8439 element.modifyInventDimField(fieldNum(InventDim, InventStyleId));
8440 element.performUpdatePostProductDimensionChange();
8441 }
8442
8443 public boolean validate()
8444 {
8445 boolean ret;
8446
8447 ret = super();
8448
8449 if (ret)
8450 {
8451 ret = salesLine.validateModifyInventDim(inventDim,fieldNum(InventDim,InventStyleId));
8452 }
8453
8454 return ret;
8455 }
8456
8457 }
8458
8459 [DataField]
8460 class LicensePlateId
8461 {
8462 public boolean validate()
8463 {
8464 boolean ret;
8465
8466 ret = super();
8467
8468 if (ret)
8469 {
8470 ret = salesLine.validateModifyInventDim(inventDim, fieldNum(InventDim, LicensePlateId));
8471 }
8472
8473 return ret;
8474 }
8475
8476 public void modified()
8477 {
8478 SalesCalcAvailableDlvDates salesCalcAvailableDlvDates;
8479
8480 super();
8481
8482 salesLine.modifyInventDim(inventDim, fieldNum(InventDim, LicensePlateId), !salesLine.MatchingAgreementLine);
8483
8484 if (salesLine.DeliveryDateControlType)
8485 {
8486 salesCalcAvailableDlvDates = SalesCalcAvailableDlvDates::newCommonSalesDlvDateType(salesLine, 0, inventDim);
8487 salesCalcAvailableDlvDates.modifiedFieldBeforeInsert(salesLine);
8488 }
8489
8490 element.mcrRefreshMarginAlert();
8491 }
8492
8493 }
8494
8495 [DataField]
8496 class wMSLocationId
8497 {
8498 public void modified()
8499 {
8500 SalesCalcAvailableDlvDates salesCalcAvailableDlvDates;
8501
8502 super();
8503
8504 salesLine.modifyInventDim(inventDim, fieldNum(InventDim,wmsLocationId), !salesLine.MatchingAgreementLine);
8505
8506 if (salesLine.DeliveryDateControlType)
8507 {
8508 salesCalcAvailableDlvDates = SalesCalcAvailableDlvDates::newCommonSalesDlvDateType(salesLine,0,inventDim);
8509 salesCalcAvailableDlvDates.modifiedFieldBeforeInsert(salesLine);
8510 }
8511
8512 element.mcrRefreshMarginAlert();
8513 }
8514
8515 public boolean validate()
8516 {
8517 boolean ret;
8518
8519 ret = super();
8520
8521 if (ret)
8522 {
8523 ret = salesLine.validateModifyInventDim(inventDim,fieldNum(InventDim,wmsLocationId));
8524 }
8525
8526 return ret;
8527 }
8528
8529 }
8530
8531 }
8532
8533 [DataSource]
8534 class WHSSalesLine
8535 {
8536 public void write()
8537 {
8538 if (whsSalesLine.RecId)
8539 {
8540 super();
8541 }
8542 }
8543
8544 public boolean validateWrite()
8545 {
8546 boolean ret;
8547
8548 if (whsSalesLine.RecId)
8549 {
8550 ret = super();
8551 }
8552 else
8553 {
8554 ret = true;
8555 }
8556
8557 return ret;
8558 }
8559
8560 }
8561
8562 [DataSource]
8563 class TMSSalesTable
8564 {
8565 /// <summary>
8566 /// Persists a record in the database when super is called.
8567 /// </summary>
8568 public void write()
8569 {
8570 super();
8571
8572 if (!tmsSalesTable.mustBeSaved())
8573 {
8574 TMSSalesTable blankTMSSalesTable;
8575 TMSSalesTable.data(blankTMSSalesTable);
8576 }
8577 }
8578
8579 /// <summary>
8580 /// Determines whether the current record is valid and ready to be written to the database.
8581 /// </summary>
8582 /// <returns>
8583 /// true if the record is valid; otherwise, false.
8584 /// </returns>
8585 public boolean validateWrite()
8586 {
8587 if (!tmsSalesTable.SalesId)
8588 {
8589 tmsSalesTable.SalesId = salesTable.SalesId;
8590 }
8591
8592 return super();
8593 }
8594
8595 public int active()
8596 {
8597 int ret;
8598
8599 ret = super();
8600
8601 element.enableTMSFields();
8602
8603 return ret;
8604 }
8605
8606 [DataField]
8607 class CarrierCode
8608 {
8609 public void modified()
8610 {
8611 if (tmsSalesTable.RecId == 0)
8612 {
8613 tmsSalesTable.initFromSalesTable(salesTable.SalesId);
8614 }
8615
8616 super();
8617
8618 if (!tmsSalesTable.CarrierCode
8619 || !TMSCarrierService::exist(tmsSalesTable.CarrierServiceCode, tmsSalesTable.CarrierCode))
8620 {
8621 tmsSalesTable.CarrierServiceCode = "";
8622 }
8623
8624 tmsSalesTable.ModeCode = TMSCarrier::find(tmsSalesTable.CarrierCode).ModeCode;
8625
8626 tmsSalesTable_ds.refresh();
8627
8628 element.tmsUpdateSalesOrder();
8629
8630 element.enableTMSFields();
8631 }
8632
8633 }
8634
8635 [DataField]
8636 class CarrierServiceCode
8637 {
8638 public void modified()
8639 {
8640 if (tmsSalesTable.RecId == 0)
8641 {
8642 tmsSalesTable.initFromSalesTable(salesTable.SalesId);
8643 }
8644
8645 super();
8646
8647 element.tmsUpdateSalesOrder();
8648
8649 element.enableTMSFields();
8650 }
8651
8652 }
8653
8654 [DataField]
8655 class ModeCode
8656 {
8657 public void modified()
8658 {
8659 if (tmsSalesTable.RecId == 0)
8660 {
8661 tmsSalesTable.initFromSalesTable(salesTable.SalesId);
8662 }
8663
8664 super();
8665
8666 element.enableTMSFields();
8667 }
8668
8669 }
8670
8671 }
8672
8673 [DataSource]
8674 class EximSalesLine_IN
8675 {
8676 public void init()
8677 {
8678 if (isIN)
8679 {
8680 this.linkType(FormLinkType::Active);
8681 }
8682
8683 super();
8684 }
8685
8686 public int active()
8687 {
8688 int ret;
8689
8690 ret = super();
8691
8692 if (ret)
8693 {
8694 element.enableFieldsActive_IN();
8695 }
8696
8697 return ret;
8698 }
8699
8700 public void write()
8701 {
8702 if (salesLine.RecId)
8703 {
8704 if (!EximSalesLine_IN::findBySalesLineRecId(salesLine.RecId).RecId)
8705 {
8706 eximSalesLine_IN.SalesLineRecId = salesLine.RecId;
8707 }
8708 super();
8709 }
8710 }
8711
8712 }
8713
8714 [DataSource]
8715 class SalesLine_BR
8716 {
8717 /// <summary>
8718 /// Sets which fields should be enabled in the form datasource.
8719 /// </summary>
8720 public void enableDataSourceFields_BR()
8721 {
8722 FormDataObject formDataObject;
8723
8724 formDataObject = salesLine_BR_DS.object(fieldNum(SalesLine_BR, FiscalDocumentType_BR));
8725 formDataObject.allowEdit(salesTable.hasIssueFiscalDocument_BR());
8726
8727 formDataObject = salesLine_BR_DS.object(fieldNum(SalesLine_BR, TaxServiceCode_BR));
8728 formDataObject.allowEdit(salesLine.inventTable().ItemType == ItemType::Service);
8729 }
8730
8731 public void init()
8732 {
8733 boolean isBrazilParametersEnabled = BrazilParameters::isEnabled();
8734
8735 if (isBrazilParametersEnabled)
8736 {
8737 this.linkType(FormLinkType::OuterJoin);
8738 }
8739
8740 super();
8741
8742 if (isBrazilParametersEnabled)
8743 {
8744 element.formRunHelper().addExtensionTablePair(salesLine, salesLine_BR);
8745 }
8746 }
8747
8748 public void write()
8749 {
8750 if (BrazilParameters::isEnabled() && salesLine_BR.SalesLine)
8751 {
8752 // no-op because a record with an empty FK is not valid
8753 super();
8754 }
8755 }
8756
8757 [DataField]
8758 class CFOPTable_BR
8759 {
8760 public Common lookupReference(FormReferenceControl _formReferenceControl)
8761 {
8762 Common ret;
8763 CFOPAttributesDeterminer_BR cfopAttributes;
8764
8765 if (BrazilParameters::isEnabled())
8766 {
8767 cfopAttributes = CFOPAttributesDeterminer_BR::construct(salesLine);
8768 cfopAttributes.parmFiscalEstablishment(inventDim.inventSite().fiscalEstablishment());
8769
8770 ret = CFOPLookupHelper_BR::lookupCFOPTable(_formReferenceControl, cfopAttributes);
8771 }
8772
8773 return ret;
8774 }
8775
8776 public void modified()
8777 {
8778 super();
8779
8780 buttonLineFiscalDocumentText_BR.enabled(salesLine.type().canFiscalDocTextBeRegistrated_BR());
8781
8782 salesLine_ds.enableDataSourceFields_BR();
8783 salesLine_ds.refresh();
8784 }
8785
8786 }
8787
8788 [DataField]
8789 class FiscalDocumentType_BR
8790 {
8791 public Common lookupReference(FormReferenceControl _formReferenceControl)
8792 {
8793 return FiscalDocumentType_BR::lookupReference(salesLine.inventDim().inventSite().fiscalEstablishment().RecId, _formReferenceControl);
8794 }
8795
8796 public Common resolveReference(FormReferenceControl _formReferenceControl)
8797 {
8798 Common ret;
8799 FiscalDocumentTypeId_BR fiscalDocumentTypeId;
8800
8801 // Get the text that the user entered into the control to see if there is a match to display
8802 fiscalDocumentTypeId = _formReferenceControl.filterValue(AbsoluteFieldBinding::construct(fieldStr(FiscalDocumentType_BR, FiscalDocumentTypeId), tableStr(FiscalDocumentType_BR))).value();
8803
8804 if (fiscalDocumentTypeId)
8805 {
8806 ret = FiscalDocumentType_BR::find
8807 (
8808 fiscalDocumentTypeId,
8809 salesLine.inventDim().inventSite().fiscalEstablishment().FiscalEstablishmentId
8810 );
8811 }
8812 else
8813 {
8814 ret = super(_formReferenceControl);
8815 }
8816 return ret;
8817 }
8818
8819 }
8820
8821 [DataField]
8822 class TaxServiceCode_BR
8823 {
8824 public void lookup(FormControl _formControl, str _filterStr)
8825 {
8826 NoYes serviceCodeOnDlvAddress;
8827 LogisticsPostalAddress logisticsPostalAddress;
8828
8829 if (salesTable.ProjId)
8830 {
8831 serviceCodeOnDlvAddress = salesTable.projTable().projInvoice().TaxServiceCodeOnDlvAddress_BR;
8832 logisticsPostalAddress = LogisticsPostalAddress::findRecId(salesTable.projTable().postalAddress().RecId);
8833 }
8834 else
8835 {
8836 serviceCodeOnDlvAddress = salesTable.salesTable_BR().ServiceCodeOnDlvAddress_BR;
8837 logisticsPostalAddress = LogisticsLocationEntity::location2PostalAddress(salesLine.deliveryLocation());
8838 }
8839
8840 TaxServiceCode_BR::lookup(_formControl, serviceCodeOnDlvAddress,
8841 logisticsPostalAddress.CountryRegionId,
8842 logisticsPostalAddress.State,
8843 logisticsPostalAddress.City);
8844 }
8845
8846 }
8847
8848 }
8849
8850 [DataSource]
8851 class SalesLine_IN
8852 {
8853 public void write()
8854 {
8855 if (isSalesLine_INEnabled && salesLine_IN.SalesLine != 0)
8856 {
8857 salesLine.type().update_IN();
8858
8859 // no-op because a record with an empty FK is not valid
8860 super();
8861
8862 if (!salesLineReturnDetails_IN.RecId && salesLineReturnDetails_IN.Type != SalesReturnType_IN::None)
8863 {
8864 // need to force the write in the create case since the form won't do it.
8865 salesLineReturnDetails_IN.SalesLine_IN = salesLine_IN.RecId;
8866 salesLineReturnDetails_IN_ds.write();
8867 }
8868 }
8869 }
8870
8871 public void init()
8872 {
8873 if (isSalesLine_INEnabled)
8874 {
8875 this.linkType(FormLinkType::OuterJoin);
8876 }
8877 super();
8878
8879 if (isSalesLine_INEnabled)
8880 {
8881 element.formRunHelper().addExtensionTablePair(salesLine, salesLine_IN);
8882 }
8883 }
8884
8885 [DataField]
8886 class TCSGroup
8887 {
8888 public void lookup(FormControl _formControl, str _filterStr)
8889 {
8890 TaxWithholdGroupHeading::lookupTaxComponentGroup_IN(_formControl, TaxWithholdCodeType_IN::TCS);
8891 }
8892
8893 public void modified()
8894 {
8895 super();
8896 element.setTaxWithholdEnabled_IN();
8897 }
8898
8899 }
8900
8901 [DataField]
8902 class TDSGroup
8903 {
8904 public void lookup(FormControl _formControl, str _filterStr)
8905 {
8906 TaxWithholdGroupHeading::lookupTaxComponentGroup_IN(_formControl, TaxWithholdCodeType_IN::TDS);
8907 }
8908
8909 public void modified()
8910 {
8911 super();
8912 element.setTaxWithholdEnabled_IN();
8913 }
8914
8915 }
8916
8917 }
8918
8919 [DataSource]
8920 class SalesLine_Intrastat
8921 {
8922 public void init()
8923 {
8924 boolean isLegalEntityInCountryRegionIsoCZEnabled = SysCountryRegionCode::isLegalEntityInCountryRegion([#isoCZ]);
8925
8926 if (isLegalEntityInCountryRegionIsoCZEnabled)
8927 {
8928 // Only enable the symbol datasource if the country context is correct
8929 salesLine_intrastat_DS.linkType(FormLinkType::OuterJoin);
8930 }
8931 super();
8932
8933 if (isLegalEntityInCountryRegionIsoCZEnabled)
8934 {
8935 element.formRunHelper().addExtensionTablePair(salesLine, salesLine_Intrastat);
8936 }
8937 }
8938
8939 }
8940
8941 [DataSource]
8942 class SalesTable_BR
8943 {
8944 public void enableDataSourceFields_BR()
8945 {
8946 FormDataObject formDataObject;
8947
8948 formDataObject = salesTable_BR_DS.object(fieldNum(SalesTable_BR, CustFinalUser_BR));
8949 formDataObject.allowEdit(!salesTable.custTable_InvoiceAccount().Suframa_BR);
8950
8951 formDataObject = salesTable_BR_DS.object(fieldNum(SalesTable_BR, SalesPurchOperationType_BR));
8952 formDataObject.allowEdit(salesTable.type().canEditSalesPurchOperationType_BR());
8953
8954 formDataObject = salesLine_BR_DS.object(fieldNum(SalesLine_BR, DeliveryCFOPTable_BR));
8955 formDataObject.allowEdit(salesTable.SalesType == SalesType::ItemReq);
8956
8957 OpenTrans.visible(SalesTable.createCustTrans_BR());
8958 buttonPaymentSchedule.visible(SalesTable.createCustTrans_BR());
8959 }
8960
8961 public void init()
8962 {
8963 boolean isBrazilParametersEnabled = BrazilParameters::isEnabled();
8964
8965 if (isBrazilParametersEnabled)
8966 {
8967 this.linkType(FormLinkType::OuterJoin);
8968 }
8969
8970 super();
8971
8972 if (isBrazilParametersEnabled)
8973 {
8974 element.formRunHelper().addExtensionTablePair(salesTable, salesTable_BR);
8975 }
8976 }
8977
8978 public display NoYes displaySuframaPISCOFINS_BR()
8979 {
8980 return salesTable.custTable_InvoiceAccount().SuframaPISCOFINS_BR;
8981 }
8982
8983 public display CustSuframa_BR displaySuframa_BR()
8984 {
8985 return salesTable.custTable_InvoiceAccount().Suframa_BR;
8986 }
8987
8988 public void write()
8989 {
8990 if (BrazilParameters::isEnabled() && salesTable_BR.SalesTable)
8991 {
8992 // no-op because a record with an empty FK is not valid
8993 super();
8994 }
8995 }
8996
8997 [DataField]
8998 class CFPSId_BR
8999 {
9000 public void lookup(FormControl _formControl, str _filterStr)
9001 {
9002 CFPSTable_BR::lookup(_formControl, SalesPurchBoth_BR::Sales);
9003 }
9004
9005 }
9006
9007 [DataField]
9008 class SalesPurchOperationType_BR
9009 {
9010 public boolean validate()
9011 {
9012 CFOPAttributesDeterminer_BR cfopAttributesDeterminer;
9013 boolean ret;
9014
9015 cfopAttributesDeterminer = CFOPAttributesDeterminer_BR::construct(salesLine);
9016
9017 ret = salesPurchOperationTypeController_BR.validate(salesTable_BR.SalesPurchOperationType_BR, cfopAttributesDeterminer);
9018
9019 if (ret && !salesTable.createInventTrans_BR())
9020 {
9021 if (Box::yesNo("@GLS104", DialogButton::No) == DialogButton::No)
9022 {
9023 return false;
9024 }
9025 }
9026
9027 return super() && ret;
9028 }
9029
9030 public Common lookupReference(FormReferenceControl _formReferenceControl)
9031 {
9032 CFOPAttributesDeterminer_BR cfopAttributesDeterminer;
9033 SalesPurchOperationTypeController_BR s;
9034
9035 GlobalizationInstrumentationHelper::featureRun(GlobalizationConstants::FeatureReferenceBR00007, funcName());
9036 cfopAttributesDeterminer = CFOPAttributesDeterminer_BR::construct(salesLine);
9037 s = new SalesPurchOperationTypeController_BR (element.name());
9038 return s.lookupReference(_formReferenceControl, cfopAttributesDeterminer);
9039 }
9040
9041 }
9042
9043 }
9044
9045 [DataSource]
9046 class SalesTable_Intrastat
9047 {
9048 public void init()
9049 {
9050 boolean isLegalEntityInCountryRegionIsoCZEnabled = SysCountryRegionCode::isLegalEntityInCountryRegion([#isoCZ]);
9051
9052 if (isLegalEntityInCountryRegionIsoCZEnabled)
9053 {
9054 // Only enable the symbol datasource if the country context is correct
9055 salesTable_intrastat_DS.linkType(FormLinkType::OuterJoin);
9056 }
9057
9058 super();
9059
9060 if (isLegalEntityInCountryRegionIsoCZEnabled)
9061 {
9062 element.formRunHelper().addExtensionTablePair(salesTable, salesTable_Intrastat);
9063 }
9064 }
9065
9066 }
9067
9068 [DataSource]
9069 class TaxServiceTariffLine
9070 {
9071 public void write()
9072 {
9073 if (countryRegion_PL)
9074 {
9075 if (!taxServiceTariffLine.ParentRecId)
9076 {
9077 taxServiceTariffLine.ParentRecId = salesLine.RecId;
9078 }
9079
9080 if (!taxServiceTariffLine.ParentTableId)
9081 {
9082 taxServiceTariffLine.ParentTableId = salesLine.TableId;
9083 }
9084 }
9085
9086 super();
9087 }
9088
9089 public void create(boolean _append = false)
9090 {
9091 super(_append);
9092
9093 if (taxServiceTariffHeader.ServiceTariffNumber && !salesLine.RecId && countryRegion_PL)
9094 {
9095 taxServiceTariffLine.ServiceTariffNumber = taxServiceTariffHeader.ServiceTariffNumber;
9096 }
9097 }
9098
9099 }
9100
9101 [DataSource]
9102 class SalesTable_RU
9103 {
9104 public void init()
9105 {
9106 if (isRU)
9107 {
9108 switch (element.args().dataset())
9109 {
9110 case tableNum(SalesAgreementHeaderExt_RU):
9111 if (element.args().record())
9112 {
9113 this.linkType(FormLinkType::InnerJoin);
9114 }
9115 break;
9116
9117 default :
9118 this.linkType(FormLinkType::OuterJoin);
9119 break;
9120 }
9121 }
9122
9123 super();
9124
9125 if (isRU)
9126 {
9127 switch (element.args().dataset())
9128 {
9129 case tableNum(SalesAgreementHeaderExt_RU):
9130 if (element.args().record())
9131 {
9132 this.query().dataSourceTable(tableNum(SalesTable_RU)).clearDynalinks();
9133 this.query().dataSourceTable(tableNum(SalesTable_RU)).addDynalink(
9134 fieldNum(SalesTable_RU, AgreementHeaderExt_RU),
9135 element.args().record(),
9136 fieldNum(AgreementHeaderExt_RU, RecId));
9137 }
9138 break;
9139 }
9140
9141 element.formRunHelper().addExtensionTablePair(salesTable, salesTable_RU);
9142 }
9143 }
9144
9145 public void write()
9146 {
9147 if (isRU && salesTable_RU.SalesTable != 0)
9148 {
9149 // no-op because a record with an empty FK is not valid
9150 super();
9151 }
9152 }
9153
9154 [DataField]
9155 class AgreementHeaderExt_RU
9156 {
9157 public void modified()
9158 {
9159 super();
9160
9161 // force a refresh because the agreement document title is indirectly related on a different datasource
9162 salesTable_DS.cacheCalculateMethod(tableMethodStr(SalesTable, agreementDocumentTitle_RU));
9163 salesTable_DS.refresh();
9164 }
9165
9166 public Common lookupReference(FormReferenceControl _formReferenceControl)
9167 {
9168 Common ret;
9169
9170 ret = SalesAgreementHeaderExt_RU::salesAgreementReferenceLookup(_formReferenceControl,
9171 salesTable.CustAccount,
9172 salesTable.ShippingDateRequested,
9173 salesTable.InvoiceAccount);
9174
9175 return ret;
9176 }
9177
9178 public void jumpRef()
9179 {
9180 SalesAgreementHeaderExt_RU::salesAgreementJumpRef(salesTable_RU.AgreementHeaderExt_RU);
9181 }
9182
9183 }
9184
9185 [DataField]
9186 class ConsigneeAccount_RU
9187 {
9188 public void lookup(FormControl _formControl, str _filterStr)
9189 {
9190 CustTable::lookupCustomer(_formControl);
9191 }
9192
9193 }
9194
9195 [DataField]
9196 class ConsignorAccount_RU
9197 {
9198 public void lookup(FormControl _formControl, str _filterStr)
9199 {
9200 VendTable::lookupVendor(_formControl);
9201 }
9202
9203 }
9204
9205 [DataField]
9206 class InventProfileId_RU
9207 {
9208 public void lookup(FormControl _formControl, str _filterStr)
9209 {
9210 if (salesTable_RU.InventProfileType_RU != InventProfileType_RU::NotSpecified)
9211 {
9212 InventProfile_RU::lookupInventProfileId(_formControl, salesTable_RU.InventProfileType_RU);
9213 }
9214 }
9215
9216 public boolean validate()
9217 {
9218 boolean ret = true;
9219
9220 if (salesTable_RU.InventProfileType_RU == InventProfileType_RU::NotSpecified && salesTable_RU.InventProfileId_RU)
9221 {
9222 ret = false;
9223 }
9224 ret = ret && super();
9225
9226 return ret;
9227 }
9228
9229 }
9230
9231 [DataField]
9232 class PriceAgreementDate_RU
9233 {
9234 public void modified()
9235 {
9236 super();
9237 element.automaticTotalDiscount();
9238 }
9239
9240 }
9241
9242 }
9243
9244 [DataSource]
9245 class SalesTableExtensionTH
9246 {
9247 public void write()
9248 {
9249 if (salesTable.RecId)
9250 {
9251 salesTableExtensionTH.SalesTable = salesTable.RecId;
9252 super();
9253 }
9254 }
9255
9256 public void init()
9257 {
9258 isSalesTableExtensionTHEnabled = SalesTableExtensionTH::isExtensionEnabled();
9259 if (isSalesTableExtensionTHEnabled)
9260 {
9261 this.linkType(FormLinkType::OuterJoin);
9262 }
9263
9264 super();
9265
9266 if (isSalesTableExtensionTHEnabled)
9267 {
9268 element.formRunHelper().addExtensionTablePair(salesTable, salesTableExtensionTH);
9269 }
9270 }
9271
9272 [DataField]
9273 class InvoicePostalAddress
9274 {
9275 public Common lookupReference(FormReferenceControl _formReferenceControl)
9276 {
9277 Common ret;
9278 CustTable custTable = CustTable::find(salesTable.InvoiceAccount);
9279
9280 ret = LogisticsLocationSelectionLookup::lookupAddressForm(_formReferenceControl, custTable, [LogisticsLocationRoleType::Invoice], false);
9281 return ret;
9282 }
9283
9284 }
9285
9286 [DataField]
9287 class NoteFormat
9288 {
9289 public void modified()
9290 {
9291 super();
9292 element.noteFormatEdit();
9293 }
9294
9295 }
9296
9297 }
9298
9299 [DataSource]
9300 class MCRSalesTable
9301 {
9302 public void init()
9303 {
9304 super();
9305
9306 element.formRunHelper().addExtensionTablePair(salesTable, mcrSalesTable);
9307 }
9308
9309 public void write()
9310 {
9311 if (!mcrSalesTable.SalesTable)
9312 {
9313 mcrSalesTable.SalesTable = salesTable.RecId;
9314 }
9315 if (mcrSalesTable.SalesTable
9316 && mcrSalesTable.validateMCRSalesTableUsed())
9317 {
9318 // no-op because a record with an empty FK is not valid.
9319 super();
9320 }
9321 }
9322
9323 public boolean leaveRecord(boolean _forceUpdate = false)
9324 {
9325 boolean ret;
9326
9327 if (mcrSalesTable.SalesTable)
9328 {
9329 ret = super(_forceUpdate);
9330 }
9331 else
9332 {
9333 ret = true;
9334 }
9335
9336 return ret;
9337 }
9338
9339 [DataField]
9340 class PriceOverride
9341 {
9342 public void modified()
9343 {
9344 super();
9345
9346 if (#MCRPriceOverrideEnabled)
9347 {
9348 element.mcrHeaderPriceOverride(true, "", curUserId());
9349
9350 salesTable_ds.refresh();
9351 }
9352 }
9353
9354 }
9355
9356 [DataField]
9357 class SourceId
9358 {
9359 public void modified()
9360 {
9361 MCRDefaultDimensions mcrDefaultDimensionsLocal;
9362 MCRSourceCode mcrSourceCodeLocal;
9363 CustTable custTableLocal;
9364 boolean hasSalesLine = false;
9365
9366 super();
9367
9368 RetailSalesOrderCalculatorCache::removeCachedSalesLineForSalesOrder(salesTable);
9369
9370 if (mcrSalesTable.SourceId != mcrSalesTable.orig().SourceId)
9371 {
9372 // Blank out the dimension on source code modified, this way
9373 // the defaulting will come from the hierarchy set up on the AR parameters
9374 // field AccountRevenue.
9375 salesTable.DefaultDimension = 0;
9376
9377 // Check if there's any sales line
9378 hasSalesLine = SalesLine::find(salesTable.SalesId).RecId != 0;
9379
9380 // Update SourceId to SalesLine if SourceId is not blank and user chooses yes in the prompt
9381 if (hasSalesLine && element.confirmSourceIdUpdateOnLines())
9382 {
9383 element.mcrUpdateSourceIdToSalesLines();
9384 }
9385
9386 mcrSourceCodeLocal = MCRSourceCode::construct(salesTable);
9387 if (mcrSalesTable.SourceId)
9388 {
9389 ttsbegin;
9390 mcrSalesTable.SalesTable = salesTable.RecId;
9391 mcrSalesTable.write();
9392 // Can assume source code is valid after call to MCRInitFromSourceCodeSetup.
9393 mcrSourceCodeLocal.mcrInitFromSourceCodeSetup(MCRSourceCodeSetup::find(mcrSalesTable.SourceId), salesTable.CustAccount);
9394 ttscommit;
9395 updateSalesLineSourceId = true;
9396 // Refresh for free products added if any
9397 if (hasSalesLine)
9398 {
9399 salesLine_DS.research(true);
9400 }
9401 }
9402 else
9403 {
9404 custTableLocal = CustTable::find(salesTable.CustAccount);
9405 salesTable.MultiLineDisc = custTableLocal.MultiLineDisc;
9406 salesTable.EndDisc = custTableLocal.EndDisc;
9407 salesTable.DeliveryDate = DateTimeUtil::getSystemDate(DateTimeUtil::getUserPreferredTimeZone());
9408
9409 mcrDefaultDimensionsLocal = MCRDefaultDimensions::construct(salesTable);
9410 mcrDefaultDimensionsLocal.setDefaultDimensions();
9411 updateSalesLineSourceId = false;
9412 mcrSalesTable.update();
9413 }
9414
9415 // Update total discount now, or a user-entered change will be trapped
9416 // and considered an override, possibly of an old value, which is not
9417 // desirable.
9418 salesTable.updateFinalDisc();
9419
9420 mcrLastSourceId = mcrSalesTable.SourceId;
9421 mcrSalesTableShipping_ds.reread();
9422 mcrSalesTableShipping_ds.refresh();
9423
9424 salesTable_ds.refresh();
9425
9426 element.mcrDisplaySourceMessage();
9427 }
9428 }
9429
9430 public void lookup(FormControl _formControl, str _filterStr)
9431 {
9432 FormRun formRun;
9433 Args args;
9434
9435 args = new Args();
9436 args.name(formStr(MCRSourceIdTargetLookup));
9437 // Use SysQuery::value since this will be used in a range
9438 args.parm(SysQuery::value(salesTable.custTable_CustAccount().Party));
9439 args.caller(_formControl);
9440 formRun = ClassFactory::formRunClassOnClient(args);
9441 formRun.init();
9442 this.performFormLookup(formRun, _formControl);
9443 }
9444
9445 }
9446
9447 }
9448
9449 [DataSource]
9450 class MCRSalesTableShipping
9451 {
9452 public void init()
9453 {
9454 super();
9455
9456 element.formRunHelper().addExtensionTablePair(salesTable, mcrSalesTableShipping);
9457 }
9458
9459 public void write()
9460 {
9461 if (!mcrSalesTableShipping.SalesTable)
9462 {
9463 mcrSalesTableShipping.SalesTable = salesTable.RecId;
9464 }
9465 if (mcrSalesTableShipping.SalesTable
9466 && (mcrSalesTableShipping.validateMCRSalesTableShippingUsed() || mcrSalesTableShipping.orig().validateMCRSalesTableShippingUsed()))
9467 {
9468 // no-op because a record with an empty FK is not valid.
9469 super();
9470 }
9471 }
9472
9473 }
9474
9475 [DataSource]
9476 class MCRSalesLine
9477 {
9478 public void write()
9479 {
9480 if (mcrSalesLine.SalesLine)
9481 {
9482 if (this.validateMCRSalesLine())
9483 {
9484 super();
9485 }
9486 else if (mcrSalesLine.RecId == 0)
9487 {
9488 mcrSalesLine.SalesLine = 0;
9489 }
9490 }
9491 }
9492
9493 public void init()
9494 {
9495 super();
9496
9497 element.formRunHelper().addExtensionTablePair(salesLine, mcrSalesLine);
9498 }
9499
9500 public boolean validateMCRSalesLine()
9501 {
9502 if (mcrCallCenterEnabled
9503 && (mcrSalesLine.SalesLine
9504 ||mcrSalesLine.ContinuityScheduleId
9505 || mcrSalesLine.CustInvoiceTransRecId
9506 || mcrSalesLine.Expedite
9507 || mcrSalesLine.GiftCardRecipientEmail
9508 || mcrSalesLine.GiftCardRecipientName
9509 || mcrSalesLine.GiftCardBuyerEmail
9510 || mcrSalesLine.GiftCardBuyerName
9511 || mcrSalesLine.InstallmentEligible
9512 || mcrSalesLine.LineType != MCRLineType::Regular
9513 || mcrSalesLine.ParentLotId
9514 || mcrSalesLine.UpSellOrigin
9515 || mcrSalesLine.UpSellOriginRef))
9516 {
9517 return true;
9518 }
9519
9520 return false;
9521 }
9522
9523 public boolean leaveRecord(boolean _forceUpdate = false)
9524 {
9525 boolean ret;
9526
9527 if (mcrSalesLine.SalesLine)
9528 {
9529 ret = super(_forceUpdate);
9530 }
9531 else
9532 {
9533 ret = true;
9534 }
9535
9536 return ret;
9537 }
9538
9539 public void create(boolean _append = false)
9540 {
9541 if (mcrSalesTableShipping.Expedite)
9542 {
9543 mcrSalesLine.Expedite = mcrSalesTableShipping.Expedite;
9544 }
9545
9546 //If the source code is set on the header, default it to the sales line.
9547 if (mcrSalesTable.SourceId)
9548 {
9549 mcrSalesLine.SourceId = mcrSalesTable.SourceId;
9550 MCRSourceCodeSetup souceCodeSetup = MCRSourceCodeSetup::find(mcrSalesLine.SourceId);
9551 retailSalesLine.Catalog = souceCodeSetup.Catalog;
9552 }
9553
9554 if (mcrCallCenterEnabled)
9555 {
9556 super(_append);
9557 }
9558 }
9559
9560 public boolean validateWrite()
9561 {
9562 boolean ret;
9563
9564 ret = super();
9565
9566 if (ret &&
9567 !mcrSalesLine.SalesLine &&
9568 mcrGiftCardPoliciesEnabled &&
9569 mcrProcessGiftCardsAsPrepayments_RU &&
9570 this.validateMCRSalesLine())
9571 {
9572 ret = mcrSalesLine.checkGiftCardIssuePolicies(SalesTable.CurrencyCode);
9573 }
9574
9575 return ret;
9576 }
9577
9578 /// <summary>
9579 /// Update gift card price by the policy according to gift card number
9580 /// </summary>
9581 public void giftCardPolicyChanged()
9582 {
9583 RetailGiftCardFaceValue retailGiftCardFaceValue;
9584 if (mcrGiftCardPoliciesEnabled)
9585 {
9586 retailGiftCardFaceValue = giftCardPolicyCache.getFaceValue(MCRSalesLine.GiftCardNumber, MCRSalesLine.GiftCardType);
9587
9588 if (retailGiftCardFaceValue)
9589 {
9590 if (mcrProcessGiftCardsAsPrepayments_RU)
9591 {
9592 MCRSalesLine.GiftCardAmount_RU = retailGiftCardFaceValue;
9593 }
9594 else
9595 {
9596 SalesLine.SalesPrice = retailGiftCardFaceValue;
9597 SalesLine_ds.object(fieldNum(SalesLine, SalesPrice)).modified();
9598 }
9599 }
9600 }
9601 }
9602
9603 /// <summary>
9604 /// Displays the description of gift card policy associated with the current MCRSAlesLine.
9605 /// </summary>
9606 /// <param name="_mCRSalesLine">
9607 /// A buffer of the MCRSAlesLine table.
9608 /// </param>
9609 /// <returns>
9610 /// The description of gift card policy only if the Gift card policies feature is ON; otherwise, return empty string.
9611 /// </returns>
9612 public display RetailGiftCardPolicies policyDescription(MCRSAlesLine _mCRSalesLine)
9613 {
9614 if (!mcrGiftCardPoliciesEnabled)
9615 {
9616 return "";
9617 }
9618 return giftCardPolicyCache.getPoliciesDescription(_mCRSalesLine.GiftCardNumber, _mCRSalesLine.GiftCardType);
9619 }
9620
9621 display container mcrWorkflowIcon(MCRSalesLine _mcrSalesLine)
9622 {
9623 SymbolFontGlyphName symbol;
9624 if (_mcrSalesLine.RetailPriceOverrideWorkflowState != RetailPriceOverrideWorkflowState::None)
9625 {
9626 if (_mcrSalesLine.RetailPriceOverrideWorkflowState == RetailPriceOverrideWorkflowState::Approved)
9627 {
9628 symbol = ImageReferenceSymbol::FieldCorrect;
9629 }
9630 else if (_mcrSalesLine.RetailPriceOverrideWorkflowState == RetailPriceOverrideWorkflowState::Rejected)
9631 {
9632 symbol = ImageReferenceSymbol::Error;
9633 }
9634 else if (_mcrSalesLine.RetailPriceOverrideWorkflowState == RetailPriceOverrideWorkflowState::Submitted)
9635 {
9636 symbol = ImageReferenceSymbol::Workflow;
9637 }
9638 else
9639 {
9640 symbol = ImageReferenceSymbol::Warning;
9641 }
9642 }
9643 return ImageReference::constructForSymbol(symbol).pack();
9644 }
9645
9646 [DataField]
9647 class GiftCardType
9648 {
9649 public void modified()
9650 {
9651 super();
9652 element.mcrSetEditGiftCard();
9653
9654 MCRSalesLine_ds.giftCardPolicyChanged();
9655 }
9656
9657 }
9658
9659 [DataField]
9660 class SourceId
9661 {
9662 public void lookup(FormControl _formControl, str _filterStr)
9663 {
9664 MCRSourceCodeSetup::lookupNonExpiredSourceCodes(_formControl);
9665 }
9666
9667 public void modified()
9668 {
9669 super();
9670
9671 if (RetailPricingEngine::useRetailPricingEngineForSalesOrder(salesTable.SalesId))
9672 {
9673 // read the updated catalog id
9674 RetailSalesLine_ds.reread();
9675 RetailSalesLine_ds.refresh();
9676
9677 salesLine.InventDimId = InventDim::findOrCreate(inventDim).inventDimId;
9678 salesLine.setPriceDisc(inventDim);
9679 }
9680
9681 // Changes were made to the related sales line, need to refresh.
9682 RetailSalesLine_ds.reread();
9683 RetailSalesLine_ds.refresh();
9684 salesLine_ds.refresh();
9685 }
9686
9687 }
9688
9689 }
9690
9691 [DataSource]
9692 class MCRSalesLineDropShipment
9693 {
9694 public void init()
9695 {
9696 super();
9697
9698 element.formRunHelper().addExtensionTablePair(salesLine, mcrSalesLineDropShipment);
9699 }
9700
9701 public int active()
9702 {
9703 int ret;
9704
9705 ret = super();
9706
9707 mcrSalesLineDropShipment_ds.allowEdit(salesLine.SalesStatus != SalesStatus::Delivered && !salesLine.isCategoryBased());
9708
9709 return ret;
9710 }
9711
9712 public void write()
9713 {
9714 if (mcrSalesLineDropShipment.SalesLine)
9715 {
9716 // no-op because a record with an empty FK is not valid.
9717 super();
9718 }
9719 }
9720
9721 public boolean leaveRecord(boolean _forceUpdate = false)
9722 {
9723 boolean ret;
9724
9725 if (mcrSalesLineDropShipment.SalesLine)
9726 {
9727 ret = super(_forceUpdate);
9728 }
9729 else
9730 {
9731 ret = true;
9732 }
9733
9734 return ret;
9735 }
9736
9737 [DataField]
9738 class DropShipment
9739 {
9740 public void modified()
9741 {
9742 PurchCreateFromSalesOrder purchCreate;
9743 TmpPurchLinePrice tmpPurchLinePrice;
9744 PurchLine purchLine;
9745
9746 element.defaultInventDimBasedOnDirectDeliveryWarehouse(MCRSalesLineDropShipment.DropShipment);
9747
9748 // Set the direct delivery status
9749 if (!mcrSaleslineDropShipment.DropShipment)
9750 {
9751 mcrSaleslineDropShipment.DropShipStatus = MCRDropShipStatus::None;
9752 }
9753 else
9754 {
9755 element.initializeTmpPurchLinePriceFromSalesLine(tmpPurchLinePrice);
9756 tmpPurchLinePrice.insert();
9757
9758 purchCreate = PurchCreateFromSalesOrder::newPurchCreateFromSalesOrder(TradeLineDlvType::DropShip);
9759 purchCreate.parmTmpPurchLinePrice(tmpPurchLinePrice);
9760 purchCreate.parmSalesTable(salesTable);
9761
9762 if (!purchCreate.checkSelectedLines())
9763 {
9764 mcrSaleslineDropShipment.DropShipment = NoYes::No;
9765 return;
9766 }
9767
9768 mcrSaleslineDropShipment.DropShipStatus = MCRDropShipStatus::ToBeDropShipped;
9769 }
9770
9771 super();
9772
9773 // The call to salesLine_ds.write() will take care of deleting related direct delivery purchase line when un-selecting drop shipment flag.
9774 // This is conditioned only if the related direct delivery purchase line exists and can be deleted.
9775 if (salesLine.InventRefType == InventRefType::Purch
9776 && !mcrSalesLineDropShipment.DropShipment
9777 && mcrSalesLineDropShipment.orig().DropShipment)
9778 {
9779 purchLine = PurchLine::findInventTransId(salesLine.InventRefTransId);
9780 if (purchLine && purchLine.isDropShipment())
9781 {
9782 if (mcrSalesLineDropShipment.validateWrite()
9783 && salesLine.warningForReference()) // salesLine_ds.write() will do call that deletes related PO. Need to ensure the user's acceptance of this
9784 {
9785 salesLine_ds.write();
9786 }
9787 mcrSalesLineDropShipment_ds.reread();
9788 }
9789 }
9790
9791 salesline_ds.refresh();
9792 }
9793
9794 }
9795
9796 }
9797
9798 [DataSource]
9799 class MCRSalesLinePriceOverride
9800 {
9801 public void init()
9802 {
9803 super();
9804
9805 element.formRunHelper().addExtensionTablePair(salesLine, mcrSalesLinePriceOverride);
9806 }
9807
9808 public void write()
9809 {
9810 if (mcrSalesLinePriceOverride.SalesLine)
9811 {
9812 // no-op because a record with an empty FK is not valid.
9813 super();
9814 }
9815 }
9816
9817 public boolean leaveRecord(boolean _forceUpdate = false)
9818 {
9819 boolean ret;
9820
9821 if (mcrSalesLinePriceOverride.SalesLine)
9822 {
9823 ret = super(_forceUpdate);
9824 }
9825 else
9826 {
9827 ret = true;
9828 }
9829
9830 return ret;
9831 }
9832
9833 [DataField]
9834 class PriceOverride
9835 {
9836 public void modified()
9837 {
9838 super();
9839
9840 if (#MCRPriceOverrideEnabled)
9841 {
9842 // Releases price override on line.
9843 element.mcrLinePriceOverrideNo(curUserId());
9844
9845 salesLine.LineAmount = salesLine.calcLineAmountForced();
9846
9847 element.mcrSetLineControls();
9848
9849 salesLine_ds.refresh();
9850 }
9851 }
9852
9853 }
9854
9855 }
9856
9857 [DataSource]
9858 class MCRReturnSalesTable
9859 {
9860 public void init()
9861 {
9862 super();
9863
9864 element.formRunHelper().addExtensionTablePair(salesTable, mcrReturnSalesTable);
9865 }
9866
9867 public void write()
9868 {
9869 if (mcrReturnSalesTable.SalesTable)
9870 {
9871 // no-op because a record with an empty FK is not valid.
9872 super();
9873 }
9874 }
9875
9876 public boolean leaveRecord(boolean _forceUpdate = false)
9877 {
9878 boolean ret;
9879
9880 if (mcrReturnSalesTable.SalesTable)
9881 {
9882 ret = super(_forceUpdate);
9883 }
9884 else
9885 {
9886 ret = true;
9887 }
9888
9889 return ret;
9890 }
9891
9892 }
9893
9894 [DataSource]
9895 class SalesTable_W
9896 {
9897 public int active()
9898 {
9899 int ret;
9900
9901 ret = super();
9902
9903 if (custParameters.EntryCertificateIssuingEnabled_W)
9904 {
9905 element.allowEditIssueOwnEntryCertificate_W();
9906 }
9907
9908 return ret;
9909 }
9910
9911 public void init()
9912 {
9913 isSalesTableWEnabled = SalesTable_W::isLegalEntityInCountryRegion();
9914 if (isSalesTableWEnabled)
9915 {
9916 // Switch the link type as fields appear in the grid that require an outerjoin
9917 this.linkType(FormLinkType::OuterJoin);
9918 }
9919
9920 super();
9921
9922 if (isSalesTableWEnabled)
9923 {
9924 element.formRunHelper().addExtensionTablePair(salesTable, salesTable_W);
9925 }
9926 }
9927
9928 [DataField]
9929 class ECommerceOperatorGSTIN_IN
9930 {
9931 public Common lookupReference(FormReferenceControl _formReferenceControl)
9932 {
9933 Common ret;
9934
9935 ret = TaxRegistrationNumbers_IN::locationLookupGST(_formReferenceControl, CustTable::find(SalesTable_W.eCommerceOperator_IN).Party);
9936
9937 return ret;
9938 }
9939
9940 }
9941
9942 [DataField]
9943 class ECommerceOperator_IN
9944 {
9945 public void lookup(FormControl _formControl, str _filterStr)
9946 {
9947 CustTable::lookupCustomer(_formControl);
9948 }
9949
9950 public void modified()
9951 {
9952 if (SalesTable_W.eCommerceOperator_IN)
9953 {
9954 SalesTable_W.eCommerceOperatorGSTIN_IN = TaxInformation_IN::findDefaultbyLocation(DirPartyLocation::findPrimaryPartyLocation(CustTable::find(SalesTable_W.eCommerceOperator_IN).Party).Location).gstin;
9955 SalesTable_W.MerchantID_IN = TaxInformationCustTable_IN::findByCustTable(SalesTable_W.eCommerceOperator_IN).MerchantID;
9956 }
9957 else
9958 {
9959 SalesTable_W.eCommerceOperatorGSTIN_IN = 0;
9960 SalesTable_W.MerchantID_IN = '';
9961 }
9962 super();
9963 }
9964
9965 }
9966
9967 [DataField]
9968 class ECommerceSale_IN
9969 {
9970 public void modified()
9971 {
9972 if (SalesTable_W.eCommerceSale_IN)
9973 {
9974 ECommerce_IN_ECommerceOperator_IN.enabled(true);
9975 ECommerce_IN_ECommerceOperatorGSTIN_IN.enabled(true);
9976 ECommerce_IN_MerchantID_IN.enabled(true);
9977 SalesTable_W.MerchantID_IN = TaxInformationCustTable_IN::findByCustTable(SalesTable_W.eCommerceOperator_IN).MerchantID;
9978 }
9979 else
9980 {
9981 ECommerce_IN_ECommerceOperator_IN.enabled(false);
9982 ECommerce_IN_ECommerceOperatorGSTIN_IN.enabled(false);
9983 ECommerce_IN_MerchantID_IN.enabled(false);
9984 SalesTable_W.eCommerceOperator_IN = '';
9985 SalesTable_W.MerchantID_IN = '';
9986 SalesTable_W.eCommerceOperatorGSTIN_IN = 0;
9987 }
9988 super();
9989 }
9990
9991 }
9992
9993 [DataField]
9994 class EntryCertificateRequired_W
9995 {
9996 public void modified()
9997 {
9998 super();
9999 element.allowEditIssueOwnEntryCertificate_W();
10000 }
10001
10002 }
10003
10004 }
10005
10006 [DataSource]
10007 class SalesLineReturnDetails_IN
10008 {
10009 /// <summary>
10010 /// Sets which fields should be enabled in the form datasource.
10011 /// </summary>
10012 public void enableSalesLineReturnDataSource()
10013 {
10014 if (isIndiaIndirectTaxParameterMarked
10015 && salesLine_IN.RecId
10016 && salesLine.SalesQty
10017 && (salesLine.creditNoteLine(salesTable) || salesTable.returnItem()))
10018 {
10019 this.linkType(FormLinkType::OuterJoin);
10020 salesLineReturnDetails_IN_ds.refresh();
10021 }
10022 else if (salesLine.SalesQty > 0)
10023 {
10024 element.setReturnDetails_IN();
10025 this.linkType(FormLinkType::Passive);
10026 }
10027 }
10028
10029 public void write()
10030 {
10031 if (isIndiaIndirectTaxParameterMarked && salesLine_IN.RecId
10032 && salesLine.SalesQty && (salesLine.creditNoteLine(salesTable) || salesTable.returnItem()))
10033 {
10034 if (!SalesLineReturnDetails_IN::findbySalesLine(salesLine_IN.RecId).RecId)
10035 {
10036 salesLineReturnDetails_IN.SalesLine_IN = salesLine_IN.RecId;
10037 }
10038 // no-op because a record with an empty FK is not valid
10039 super();
10040 }
10041 }
10042
10043 public void init()
10044 {
10045 if (isIndiaIndirectTaxParameterMarked)
10046 {
10047 this.linkType(FormLinkType::OuterJoin);
10048 }
10049 super();
10050 }
10051
10052 }
10053
10054 [DataSource]
10055 class RetailSalesLine
10056 {
10057 public void create(boolean _append = false)
10058 {
10059 //super(_append);
10060 }
10061
10062 [DataField]
10063 class LineManualDiscountPercentage
10064 {
10065 public boolean validate()
10066 {
10067 boolean ret = super();
10068
10069 if (ret && mcrCallCenterEnabled && enableOrderPriceControl)
10070 {
10071 ret = salesLine_ds.mcrGetOverrideResponse(fieldNum(RetailSalesLine, LineManualDiscountPercentage),
10072 retailSalesLine.LineManualDiscountPercentage,
10073 fieldNum(MCRPriceOverrideMarkUpGroup, DiscPercentOverride));
10074 }
10075
10076 return ret;
10077 }
10078
10079 public void modified()
10080 {
10081 super();
10082
10083 salesLine.setPriceDisc(inventDim, true);
10084
10085 element.mcrRefreshMarginAlert();
10086
10087 if (mcrCallCenterEnabled && enableOrderPriceControl)
10088 {
10089 salesLine_ds.mcrSetWorkflowApprovalStatus();
10090 }
10091 }
10092
10093 }
10094
10095 [DataField]
10096 class PriceOverrideReasonCode
10097 {
10098 /// <summary>
10099 /// Populates the lookup for the reason code field.
10100 /// </summary>
10101 /// <param name = "_formControl">
10102 /// The control to require lookup.
10103 /// </param>
10104 /// <param name = "_filterStr">
10105 /// The string to filter lookup data.
10106 /// </param>
10107 public void lookup(FormControl _formControl, str _filterStr)
10108 {
10109 super(_formControl, _filterStr);
10110 RetailMCRChannelTable::lookupPriceOverrideReasonCodes(_formControl);
10111 }
10112
10113 }
10114
10115 }
10116
10117 [DataSource]
10118 class SalesLine_W
10119 {
10120 public void write()
10121 {
10122 if (salesLine_W.SalesLine)
10123 {
10124 // no-op because a record with an empty FK is not valid
10125 super();
10126
10127 // <GMY>
10128 if (isIsoMY)
10129 {
10130 if (SalesTable.hasLinesWithRefrence_MY() && SalesTable.hasLinesWithoutRefrence_MY())
10131 {
10132 if (!isWrnPrintedMY)
10133 {
10134 warning("@SYP4860678");
10135 isWrnPrintedMY = true;
10136 }
10137 }
10138 else
10139 {
10140 isWrnPrintedMY = false;
10141 }
10142 }
10143 // <GMY>
10144 }
10145 }
10146
10147 public void init()
10148 {
10149 isSalesLineWEnabled = SysExtensionSerializerExtensionMap::isExtensionEnabled(tableNum(SalesLine_W));
10150 if (isSalesLineWEnabled)
10151 {
10152 this.linkType(FormLinkType::OuterJoin);
10153 }
10154
10155 super();
10156
10157 if (isSalesLineWEnabled)
10158 {
10159 element.formRunHelper().addExtensionTablePair(salesLine, salesLine_W);
10160 }
10161 }
10162
10163 public boolean validateWrite()
10164 {
10165 boolean ret;
10166
10167 if (SalesLine_W.SalesLine)
10168 {
10169 ret = super();
10170 }
10171 else
10172 {
10173 ret = true;
10174 }
10175
10176 // <GMY>
10177 if (ret && isIsoMY)
10178 {
10179 if (SalesLine_W.RefInvoiceId_MY && SalesLine_W.RefInvoiceDate_MY)
10180 {
10181 if (!CustInvoiceJourLookupController_MY::validateRefInvoiceInfo([SalesLine_W.RefInvoiceId_MY, SalesLine_W.RefInvoiceDate_MY, RefNum::SalesOrder]))
10182 {
10183 ret = checkFailed("@SYP4860680");
10184 }
10185 }
10186 else if ((SalesLine_W.RefInvoiceId_MY && !SalesLine_W.RefInvoiceDate_MY) || (!SalesLine_W.RefInvoiceId_MY && SalesLine_W.RefInvoiceDate_MY))
10187 {
10188 ret = checkFailed("@SYP4860689");
10189 }
10190 }
10191 // <GMY>
10192
10193 return ret;
10194 }
10195
10196 }
10197
10198 [DataSource]
10199 class RetailSalesTable
10200 {
10201 public void init()
10202 {
10203 super();
10204
10205 element.formRunHelper().addExtensionTablePair(salesTable, RetailSalesTable);
10206 }
10207
10208 public void write()
10209 {
10210 //Updates to RetailSalesTable should be done by the packed extension.
10211 if (isRetailOrder)
10212 {
10213 salesTable.packRetailSalesTable(RetailSalesTable);
10214 super();
10215
10216 element.recalculateRetailPricesDiscounts();
10217 }
10218 }
10219
10220 public boolean validateWrite()
10221 {
10222 boolean ret;
10223
10224 ret = super();
10225
10226 if (ret && RetailSalesTable.RetailLoyaltyCard)
10227 {
10228 ret = RetailLoyaltyCard::AllowToUse(SalesTable.CustAccount, RetailSalesTable.RetailLoyaltyCard);
10229 }
10230
10231 return ret;
10232 }
10233
10234 public void create(boolean _append = false)
10235 {
10236 // Disable create so non-Retail orders won't try to insert an invalid row in RetailSalesTable
10237 // super(_append);
10238 }
10239
10240 [DataField]
10241 class RetailLoyaltyCard
10242 {
10243 public Common lookupReference(FormReferenceControl _formReferenceControl)
10244 {
10245 // Build SysReferenceTableLookup object with the proper fields.
10246 SysReferenceTableLookup sysRefTableLookup = SysReferenceTableLookup::newParameters(tableNum(RetailLoyaltyCard), _formReferenceControl);
10247 sysRefTableLookup.addLookupfield(fieldNum(RetailLoyaltyCard, CardNumber));
10248 sysRefTableLookup.addLookupfield(fieldNum(RetailLoyaltyCard, Party));
10249 sysRefTableLookup.addLookupfield(fieldNum(RetailLoyaltyCard, CardTenderType));
10250
10251 // Build a query.
10252 Query lookupQuery = new Query();
10253 QueryBuildDataSource lookupQueryDataSource = lookupQuery.addDataSource(tableNum(RetailLoyaltyCard));
10254
10255 // Display the cards owned by the customer and the anonymous cards.
10256 RefRecId customerParty = CustTable::find(SalesTable.CustAccount).Party;
10257 if (customerParty)
10258 {
10259 lookupQueryDataSource.addRange(fieldNum(RetailLoyaltyCard, Party)).value(queryValue(customerParty));
10260 }
10261 lookupQueryDataSource.addRange(fieldNum(RetailLoyaltyCard, Party)).value(queryValue(0));
10262
10263 // Sort to put the owned cards on the top and then the anonymous cards
10264 lookupQueryDataSource.addOrderByField(fieldNum(RetailLoyaltyCard, Party), SortOrder::Descending);
10265 lookupQueryDataSource.addOrderByField(fieldNum(RetailLoyaltyCard, CardNumber), SortOrder::Ascending);
10266
10267 sysRefTableLookup.parmQuery(lookupQuery);
10268 return sysRefTableLookup.performFormLookup();
10269 }
10270
10271 }
10272
10273 [DataField]
10274 class TotalManualDiscountPercentage
10275 {
10276 public void modified()
10277 {
10278 super();
10279 }
10280
10281 }
10282
10283 }
10284
10285 [DataSource]
10286 class BaseDocument_IT
10287 {
10288 public int active()
10289 {
10290 int ret;
10291
10292 ret = super();
10293
10294 if (ret)
10295 {
10296 baseDocument_IT.enableFieldsDocumentType();
10297 }
10298
10299 return ret;
10300 }
10301
10302 public void init()
10303 {
10304 if (SysCountryRegionCode::isLegalEntityInCountryRegion([#isoIT]))
10305 {
10306 this.linkType(FormLinkType::Delayed);
10307 }
10308
10309 super();
10310 }
10311
10312 }
10313
10314 [DataSource]
10315 class InventDistinctProductExpanded
10316 {
10317 public void init()
10318 {
10319 super();
10320
10321 showDisplayProductNumber = InventDistinctProductExpanded::prepareInventDistinctProductDatasource(InventDistinctProductExpanded_DisplayProductNumber,
10322 this.queryBuildDataSource(),
10323 SalesLine_DS.name(),
10324 fieldNum(SalesLine, ItemId),
10325 InventDim_DS.name());
10326 }
10327
10328 }
10329
10330 [DataSource]
10331 class RetailSalesTableChannelAttributeView
10332 {
10333 public void init()
10334 {
10335 super();
10336
10337 if (isConfigurationkeyEnabled(configurationKeyNum(Retail)))
10338 {
10339 QueryBuildDataSource viewDataSource = this.query().dataSourceTable(tableNum(RetailSalesTableChannelAttributeView));
10340 viewDataSource.addDynalink(
10341 fieldNum(RetailSalesTableChannelAttributeView, SalesId),
10342 SalesLine,
10343 fieldNum(SalesLine, SalesId));
10344
10345 viewDataSource.addDynalink(
10346 fieldNum(RetailSalesTableChannelAttributeView, SalesDataAreaId),
10347 SalesLine,
10348 fieldNum(SalesLine, DataAreaId));
10349
10350 viewDataSource.addDynalink(
10351 fieldNum(RetailSalesTableChannelAttributeView, HeaderOrLineNum),
10352 SalesLine,
10353 fieldNum(SalesLine, LineNum));
10354 }
10355 }
10356
10357 }
10358
10359 [Control("MenuFunctionButton")]
10360 class Complete
10361 {
10362 void clicked()
10363 {
10364 if (!SalesTable.validateAllLinesDelivery())
10365 {
10366 return;
10367 }
10368 else
10369 {
10370 //Do not call super as logic is needed before and after call.
10371 //Also need SalesTable form to lock while order summary is open.
10372 //super();
10373 if (SalesTable.mcrValidateGiftItem())
10374 {
10375 if (element.forceCompleteReturn())
10376 {
10377 // return order
10378 element.mcrLaunchOrderSummaryForReturnExchange();
10379 element.doRefresh();
10380 }
10381 else
10382 {
10383 // normal order
10384 element.mcrLaunchOrderSummary();
10385 salesTable_ds.reread();
10386 element.mcrSwapCompleteAndModifyButtons();
10387 // Sends email to the respected person when sales order gets completed.
10388 RetailEventNotificationAction::InsertRetailOENAction(RetailEventNotificationType::OrderConfirmation, SalesTable.RecId, SalesTable);
10389 }
10390
10391 // The active method does a lot of enabling and disabling as well as calls set header control.
10392 salesTable_ds.active();
10393 }
10394 }
10395 }
10396
10397 }
10398
10399 [Control("MenuFunctionButton")]
10400 class Modify
10401 {
10402 void clicked()
10403 {
10404 //super();
10405 element.mcrModify();
10406
10407 element.mcrSwapCompleteAndModifyButtons();
10408 }
10409
10410 }
10411
10412 [Control("MenuFunctionButton")]
10413 class ButtonTotals
10414 {
10415 void clicked()
10416 {
10417 element.automaticTotalDiscount();
10418 // <GEERU>
10419 if (isRU)
10420 {
10421 if (salesTable.checkMarkupTrans_RU())
10422 {
10423 super();
10424 }
10425 }
10426 else
10427 {
10428 // </GEERU>
10429 super();
10430 // <GEERU>
10431 }
10432 // </GEERU>
10433 }
10434
10435 }
10436
10437 [Control("Button")]
10438 class MCROrderHolds
10439 {
10440 void clicked()
10441 {
10442 super();
10443
10444 // Checks for direct delivery
10445 if (!SalesTableForm::mcrEnableOrderHoldsButton(salesTable))
10446 {
10447 throw error("@SYS4160087");
10448 }
10449 else if (!SalesTableForm::mcrEnableOrderHoldsButtonInterCompany(salesTable))
10450 {
10451 throw error("@SCM:OrderHoldFailed");
10452 }
10453
10454 SalesTableForm::mcrPromptHoldOrder(salesTable);
10455 salesTable_ds.reread();
10456 salesTable_ds.refresh();
10457 salesTable_ds.active();
10458 }
10459
10460 }
10461
10462 [Control("MenuButton")]
10463 class SendEmail
10464 {
10465 void clicked()
10466 {
10467 super();
10468 RetailEventNotificationAction::creditCardProcessCompletion(
10469 false,
10470 CreditCardPaymentErrors::construct(),
10471 CreditCardOperation::Authorize,
10472 true,
10473 salesTable);
10474 }
10475
10476 }
10477
10478 [Control("MenuFunctionButton")]
10479 class TaxTransSource
10480 {
10481 void clicked()
10482 {
10483 element.automaticTotalDiscount();
10484
10485 if (!tmpSalesTableTaxTransForm || (tmpSalesTableTaxTransForm && tmpSalesTableTaxTransForm.closed()))
10486 {
10487 tmpSalesTableTaxTransForm = SalesTotals::showTax(menuitemDisplayStr(TaxTmpWorkSalesOrder), salesTable);
10488 }
10489 }
10490
10491 }
10492
10493 [Control("MenuFunctionButton")]
10494 class TaxDocumentLauncher
10495 {
10496 public void clicked()
10497 {
10498 this.parameters(classStr(TaxableDocumentDescriptorSalesOrder));
10499 super();
10500 }
10501
10502 }
10503
10504 [Control("Button")]
10505 class MultiLnDisc
10506 {
10507 void clicked()
10508 {
10509 super();
10510 element.multiLineDiscount();
10511 }
10512
10513 }
10514
10515 [Control("Button")]
10516 class EndDisc
10517 {
10518 public void clicked()
10519 {
10520 super();
10521
10522 salesTable.updateFinalDisc();
10523 // CreditLimit calculation should only be triggered if updateFinalDisc() changes the DiscPercent which is indicated by touched.
10524 if (salesTable.Touched)
10525 {
10526 // Refresh if the final discount is updated
10527 salesTable_ds.reread();
10528 salesTable_ds.refresh();
10529
10530 //This will trigger the credit limit calculation when salesTable.validateWrite is called
10531 salesTable_ds.setTouched();
10532 }
10533 }
10534
10535 }
10536
10537 [Control("MenuFunctionButton")]
10538 class SuppItemCalc_SalesHeader
10539 {
10540 void clicked()
10541 {
10542 element.automaticTotalDiscount();
10543
10544 super();
10545
10546 element.doRefresh();
10547 //This will trigger the credit limit calculation when salesTable.validateWrite is called
10548 salesTable_ds.setTouched();
10549 }
10550
10551 }
10552
10553 [Control("Button")]
10554 class TieredCharges
10555 {
10556 public void clicked()
10557 {
10558 super();
10559
10560 salesTable.calculateTieredCharges();
10561 }
10562
10563 }
10564
10565 [Control("MenuFunctionButton")]
10566 class ButtonRetailRecalculator
10567 {
10568 void clicked()
10569 {
10570 super();
10571
10572 salesLine_ds.research(true);
10573 salesLine_ds.refresh();
10574 }
10575
10576 }
10577
10578 [Control("MenuFunctionButton")]
10579 class CheckCreditLimit
10580 {
10581 void clicked()
10582 {
10583 element.automaticTotalDiscount();
10584 super();
10585 }
10586
10587 }
10588
10589 [Control("MenuFunctionButton")]
10590 class MCRSalesStatsCust
10591 {
10592 void clicked()
10593 {
10594 Args args;
10595 FormRun formRun;
10596
10597 args = new Args();
10598 args.record(CustTable::find(salesTable.CustAccount));
10599 args.caller(this);
10600 formrun = new MenuFunction(menuitemDisplayStr(MCRSalesStatsCust),MenuItemType::Display).create(args);
10601 formrun.run();
10602 formrun.wait();
10603 }
10604
10605 }
10606
10607 [Control("Button")]
10608 class ButtonInterCompanySalesTable
10609 {
10610 void clicked()
10611 {
10612 super();
10613
10614 PurchTable referencedPurchTable = element.referencedPurchTableConsideringLineSelection(true);
10615
10616 if (salesTable.SalesType == SalesType::ReturnItem)
10617 {
10618 TradeInterCompany::construct(referencedPurchTable).formRun(formStr(ReturnTable),element);
10619 }
10620 else
10621 {
10622 TradeInterCompany::construct(referencedPurchTable).formRun(formStr(SalesTable),element);
10623 }
10624 }
10625
10626 }
10627
10628 [Control("Button")]
10629 class ButtonInterCompanyOriginalSalesTable
10630 {
10631 void clicked()
10632 {
10633 super();
10634
10635 if (salesTable.SalesType == SalesType::ReturnItem)
10636 {
10637 TradeInterCompany::construct(salesTable,true).formRun(formStr(ReturnTable),element);
10638 }
10639 else
10640 {
10641 TradeInterCompany::construct(salesTable,true).formRun(formStr(SalesTable),element);
10642 }
10643 }
10644
10645 }
10646
10647 [Control("MenuFunctionButton")]
10648 class ButtonPurchTableThisCompany
10649 {
10650 void clicked()
10651 {
10652 Args args = new Args();
10653 args.record(element.referencedPurchTableConsideringLineSelection(true));
10654
10655 MenuFunction menuFunction = new MenuFunction(menuitemDisplayStr(PurchTable), MenuItemType::Display);
10656 menuFunction.run(args);
10657 }
10658
10659 }
10660
10661 [Control("Button")]
10662 class ButtonInterCompanyPurchTable
10663 {
10664 void clicked()
10665 {
10666 super();
10667
10668 TradeInterCompany::construct(salesTable).formRun(formStr(PurchTable),element);
10669 }
10670
10671 }
10672
10673 [Control("Button")]
10674 class ButtonInterCompanySalesFormLetter_Pickinglist
10675 {
10676 void clicked()
10677 {
10678 PurchTable purchTable_Reference = salesTable.referencePurchTable();
10679 SalesTableInteractionHelper salesTableInteractionHelper;
10680
10681 if (!purchTable_Reference.RecId && !purchTable_Reference.InterCompanySalesId)
10682 {
10683 throw(error("@SYS28047"));
10684 }
10685
10686 TradeInterCompany::construct(purchTable_Reference).menuFunction(classStr(SalesFormLetter_PickingList), MenuItemType::Action, element);
10687 salesTableInteractionHelper = SalesTableInteractionHelper::construct();
10688 salesTableInteractionHelper.initHeaderActions(salesTable);
10689 buttonInterCompanySalesFormLetter_Pickinglist.enabled(salesTableInteractionHelper.parmEnableICPickingListButton());
10690 }
10691
10692 }
10693
10694 [Control("MenuFunctionButton")]
10695 class buttonUpdateInvoice
10696 {
10697 void clicked()
10698 {
10699 // <GEERU>
10700 if (isRU)
10701 {
10702 salesTable.checkMarkupTrans_RU();
10703 }
10704 // </GEERU>
10705
10706 boolean canUpdateInvoice = true;
10707
10708 if (isConfigurationkeyEnabled(configurationKeyNum(CDSIntegration)))
10709 {
10710 SalesOriginInternalType salesOriginInternalType = SalesOriginInternalType::find(salesTable.SalesOriginId);
10711
10712 if (salesOriginInternalType
10713 && salesOriginInternalType.OriginType == SalesOriginType::WorkOrderIntegration
10714 && salesTableExternalWorkOrderStatus.ExternalWorkOrderStatus != SalesExternalWorkOrderStatus::ClosedPosted
10715 && Box::okCancel("@SCM:MessageValidation_SalesOrderUpdateInvoiceForNonClosedPostedWorkOrder", DialogButton::Cancel) == DialogButton::Cancel)
10716 {
10717 canUpdateInvoice = checkFailed("@SYS21533");
10718 }
10719 }
10720
10721 if (canUpdateInvoice)
10722 {
10723 super();
10724 }
10725 }
10726
10727 }
10728
10729 [Control("MenuFunctionButton")]
10730 class buttonProformaInvoice
10731 {
10732 void clicked()
10733 {
10734 // <GEERU>
10735 if (isRU)
10736 {
10737 salesTable.checkMarkupTrans_RU();
10738 }
10739 // </GEERU>
10740 super();
10741 }
10742
10743 }
10744
10745 [Control("MenuFunctionButton")]
10746 class buttonPaymentSchedule
10747 {
10748 void clicked()
10749 {
10750 CustVendPaymSched custVendPaymSched;
10751
10752 element.automaticTotalDiscount();
10753
10754 if (salesTable.PaymentSched && !CustPaymSched::exist(salesTable.TableId,salesTable.RecId))
10755 {
10756 custVendPaymSched = CustVendPaymSched::construct(SysModule::Cust,salesTable);
10757 custVendPaymSched.copyPaymSched(PaymSched::find(salesTable.PaymentSched));
10758 salesTable.createPaymentSched();
10759 }
10760
10761 super();
10762 }
10763
10764 }
10765
10766 [Control("MenuFunctionButton")]
10767 class Cov
10768 {
10769 public void clicked()
10770 {
10771 element.automaticTotalDiscount();
10772
10773 if (isRU)
10774 {
10775 if (salesTable.checkMarkupTrans_RU())
10776 {
10777 this.updateLedgerCov();
10778 super();
10779 }
10780 }
10781 else
10782 {
10783 this.updateLedgerCov();
10784 super();
10785 }
10786 }
10787
10788 public void updateLedgerCov()
10789 {
10790 if (salesTable.CovStatus == 0)
10791 {
10792 ttsbegin;
10793 salesTable.updateLedgerCov(LedgerCoverage::construct(salesTable));
10794 ttscommit;
10795 }
10796 }
10797
10798 }
10799
10800 [Control("MenuFunctionButton")]
10801 class TradeBLWIChangeCode
10802 {
10803 void clicked()
10804 {
10805 if (! salesTable.RecId)
10806 {
10807 salesTable.write();
10808 }
10809
10810 super();
10811 }
10812
10813 }
10814
10815 [Control("Button")]
10816 class PrintMgmt
10817 {
10818 void clicked()
10819 {
10820 if (salesTable_ds.cursor() == null)
10821 {
10822 return;
10823 }
10824
10825 super();
10826
10827 PrintMgmt::launchSetup(salesTableForm.printMgmtSetupContext());
10828 }
10829
10830 }
10831
10832 [Control("MenuFunctionButton")]
10833 class MCRCatalog
10834 {
10835 void clicked()
10836 {
10837 Args args;
10838 FormRun formRun;
10839
10840 args = new Args();
10841 args.record(CustTable::find(salesTable.CustAccount));
10842 args.caller(this);
10843 formrun = new MenuFunction(menuitemDisplayStr(MCRCatalogRequest),MenuItemType::Display).create(args);
10844 formrun.run();
10845 formrun.wait();
10846 }
10847
10848 }
10849
10850 [Control("MenuFunctionButton")]
10851 class MCRCustomerService
10852 {
10853 void clicked()
10854 {
10855 Args args;
10856 FormRun formRun;
10857
10858 args = new Args();
10859 args.record(CustTable::find(salesTable.CustAccount));
10860 // Pass this so that the customer service form will show the cust record.
10861 args.caller(this);
10862 formrun = new MenuFunction(menuitemDisplayStr(MCRCustomerService),MenuItemType::Display).create(args);
10863 formrun.run();
10864 formrun.wait();
10865 //Removed call to super();
10866 }
10867
10868 }
10869
10870 [Control("MenuFunctionButton")]
10871 class buttonPurchTable
10872 {
10873 void clicked()
10874 {
10875 Args args = new Args();
10876 args.record(element.referencedPurchTableConsideringLineSelection(false));
10877
10878 MenuFunction menuFunction = new MenuFunction(menuitemDisplayStr(PurchTable), MenuItemType::Display);
10879 menuFunction.run(args);
10880 }
10881
10882 }
10883
10884 [Control("MenuFunctionButton")]
10885 class AutoRate
10886 {
10887 void clicked()
10888 {
10889 super();
10890
10891 salesTable_ds.reread();
10892 tmsSalesTable_ds.reread();
10893 }
10894
10895 }
10896
10897 [Control("MenuFunctionButton")]
10898 class CopyOfDirPartyPostalAddressNewHeader
10899 {
10900 public void clicked()
10901 {
10902 super();
10903 }
10904
10905 }
10906
10907 [Control("MenuFunctionButton")]
10908 class MCRLogisticsLocationSelectHeader1
10909 {
10910 public void clicked()
10911 {
10912 super();
10913 }
10914
10915 }
10916
10917 [Control("MenuFunctionButton")]
10918 class ButtonLineQuickQuote
10919 {
10920 public void clicked()
10921 {
10922 if (SalesTableForm.editHeaderAllowed(true))
10923 {
10924 super();
10925 }
10926 }
10927
10928 }
10929
10930 [Control("MenuFunctionButton")]
10931 class RetailAddItemMenuItem
10932 {
10933 public void clicked()
10934 {
10935 if (SalesTableForm.editHeaderAllowed(true))
10936 {
10937 super();
10938 }
10939 }
10940
10941 }
10942
10943 [Control("MenuFunctionButton")]
10944 class buttonDeliverySchedule
10945 {
10946 void clicked()
10947 {
10948 SalesTable_DS.leaveRecord();
10949
10950 Args args = new Args();
10951 FormRun deliverySchedule;
10952
10953 if (salesLine.recVersion != SalesLine::findRecId(SalesLine.RecId).recVersion)
10954 {
10955 salesLine_ds.reread();
10956 salesLine_ds.selectionChanged();
10957 }
10958
10959 if (this.enabled() == false)
10960 {
10961 warning("@SCM:SalesDeliveryScheduleNotAllowed");
10962 return;
10963 }
10964
10965 args.name(formStr(SalesDeliverySchedule));
10966 args.caller(this);
10967 args.record(salesLine);
10968 deliverySchedule = classfactory.formRunClass(args);
10969
10970 deliverySchedule.run();
10971 deliverySchedule.wait();
10972
10973 if (deliverySchedule.closedOk())
10974 {
10975 mcrProcessingDeliverySchedule = true;
10976 salesLine_ds.reread();
10977 salesLine_ds.rereadReferenceDataSources();
10978 salesLine_ds.research(true);
10979 salesTable_ds.research(true);
10980 salesTableForm.setTouched(salesTable);
10981 mcrProcessingDeliverySchedule = false;
10982 }
10983 }
10984
10985 }
10986
10987 [Control("MenuFunctionButton")]
10988 class SuppItemCalc_Sales
10989 {
10990 void clicked()
10991 {
10992 element.automaticTotalDiscount();
10993
10994 super();
10995
10996 element.doRefresh();
10997 //This will trigger the credit limit calculation when salesTable.validateWrite is called
10998 salesTable_ds.setTouched();
10999 }
11000
11001 }
11002
11003 [Control("MenuButton")]
11004 class LineStripFinancials
11005 {
11006 void clicked()
11007 {
11008 // <GEEU>
11009
11010 buttonChangeTaxGroups.enabled(salesTable.canInvoiceOrderFromCurrentSalesStatus() &&
11011 salesLine.InventTransIdReturn &&
11012 salesLine.CreditNoteInternalRef_PL);
11013 // </GEEU>
11014
11015 super();
11016 }
11017
11018 }
11019
11020 [Control("MenuFunctionButton")]
11021 class LineTaxTransSource
11022 {
11023 void clicked()
11024 {
11025 element.automaticTotalDiscount();
11026 SalesTotals::showTaxLine(menuitemDisplayStr(TaxTmpWorkSalesOrder), salesTable,salesLine,element);
11027 }
11028
11029 }
11030
11031 [Control("Button")]
11032 class buttonChangeTaxGroups
11033 {
11034 void clicked()
11035 {
11036 Dialog dialog;
11037 DialogField taxGroupItem;
11038 DialogField taxGroupField;
11039
11040 super();
11041
11042 if (salesLine.CreditNoteInternalRef_PL &&
11043 salesLine.InventTransIdReturn)
11044 {
11045 dialog = new Dialog("@GLS109917");
11046 taxGroupField = dialog.addFieldValue(extendedTypeStr(TaxGroup), salesLine.TaxGroup);
11047 taxGroupItem = dialog.addFieldValue(extendedTypeStr(TaxItemGroup), salesLine.TaxItemGroup);
11048
11049 if (dialog.run())
11050 {
11051 if (taxGroupField.value())
11052 {
11053 salesLine.TaxGroup = taxGroupField.value();
11054 salesLine.TaxItemGroup = taxGroupItem.value();
11055 salesLine_ds.write();
11056 }
11057 else
11058 {
11059 Box::warning("@GLS109918");
11060 }
11061 }
11062 }
11063 }
11064
11065 }
11066
11067 [Control("MenuButton")]
11068 class ButtonLineInventory
11069 {
11070 void clicked()
11071 {
11072 // Don't allow inventory reservation for continuity items
11073 if (mcrSalesLine.ContinuityScheduleId)
11074 {
11075 buttonLineInventReservation.enabled (false);
11076 }
11077
11078 if (buttonLineInventTrans.visible() &&
11079 buttonLineInventTrans.enabled())
11080 {
11081 buttonLineInventTransGoodsInRoute_RU.visible(salesLine.hasInventTransGoodsInRoute_RU());
11082 }
11083
11084 super();
11085 }
11086
11087 }
11088
11089 [Control("MenuFunctionButton")]
11090 class MCRItemDisplay
11091 {
11092 void clicked()
11093 {
11094 Args args;
11095 FormRun formRun;
11096
11097 //Removed call to super();
11098 args = new Args();
11099 args.record(salesLine);
11100 args.caller(element);
11101
11102 formRun = new MenuFunction(menuitemDisplayStr(MCRItemDisplay), MenuItemType::Display).create(args);
11103
11104 formRun.run();
11105 formRun.wait();
11106
11107 // If the line hasn't been saved, there is no way more lines could have
11108 // been added, so there is no need to re-execute the query.
11109 if (salesLine.RecId)
11110 {
11111 salesLine_ds.executeQuery();
11112 salesLine_ds.last();
11113 }
11114 }
11115
11116 }
11117
11118 [Control("Button")]
11119 class InterCompanyRemoveMarking
11120 {
11121 void clicked()
11122 {
11123 super();
11124
11125 TradeInterCompany::removeMarking(salesLine,element);
11126 }
11127
11128 }
11129
11130 [Control("MenuButton")]
11131 class LineStripProduct
11132 {
11133 void clicked()
11134 {
11135 super();
11136 // <GIN>
11137 if (TaxParameters::isCustomsEnable_IN()
11138 && EximParameters_IN::checkParameters())
11139 {
11140 element.enableEximInquiry_IN();
11141 }
11142 // </GIN>
11143 }
11144
11145 }
11146
11147 [Control("MenuFunctionButton")]
11148 class ButtonWithholdTax_IN
11149 {
11150 void clicked()
11151 {
11152 if (TaxWithholdParameters_IN::checkTaxParameters())
11153 {
11154 SalesTotals::showWithholdTaxLine_IN(salesTable, salesLine, element);
11155 }
11156 }
11157
11158 }
11159
11160 [Control("Button")]
11161 class buttonLineProduction
11162 {
11163 void clicked()
11164 {
11165 salesLine.type().formProduction(element);
11166 }
11167
11168 }
11169
11170 [Control("MenuFunctionButton")]
11171 class PmfBatchOrderNew
11172 {
11173 void clicked()
11174 {
11175 salesLine.type().formProduction(element);
11176 }
11177
11178 }
11179
11180 [Control("Button")]
11181 class PCExecute
11182 {
11183 void clicked()
11184 {
11185 element.pcConfigureLine();
11186 }
11187
11188 }
11189
11190 [Control("MenuFunctionButton")]
11191 class MCRUpdateGiftCard
11192 {
11193 void clicked()
11194 {
11195 super();
11196
11197 mcrSalesLine_ds.refresh();
11198 }
11199
11200 }
11201
11202 [Control("MenuFunctionButton")]
11203 class ResetFulfillmentStatus
11204 {
11205 /// <summary>
11206 /// Resets the fulfillment status of a rejected line.
11207 /// </summary>
11208 public void clicked()
11209 {
11210 // Update the fulfillment line status if the order is rejected
11211 if (retailSalesLine && retailSalesLine.FulfillmentStatus == RetailFulfillmentLineStatus::Rejected)
11212 {
11213 RetailTransactionServiceFulfillment::updateFulfillmentStatusFromEditSalesLine(salesLine, true);
11214 element.doRefresh();
11215 }
11216 }
11217
11218 }
11219
11220 [Control("Button")]
11221 class CreateLink
11222 {
11223 void clicked()
11224 {
11225 element.createAgreementLink();
11226 }
11227
11228 }
11229
11230 [Control("Button")]
11231 class RemoveLink
11232 {
11233 void clicked()
11234 {
11235 element.removeAgreementLink();
11236 }
11237
11238 }
11239
11240 [Control("MenuButton")]
11241 class LineStripFinancialsSMB
11242 {
11243 void clicked()
11244 {
11245 // <GEEU>
11246
11247 buttonChangeTaxGroups.enabled(salesTable.canInvoiceOrderFromCurrentSalesStatus() &&
11248 salesLine.InventTransIdReturn &&
11249 salesLine.CreditNoteInternalRef_PL);
11250 // </GEEU>
11251
11252 super();
11253 }
11254
11255 }
11256
11257 [Control("MenuFunctionButton")]
11258 class LineTaxTransSourceSMB
11259 {
11260 void clicked()
11261 {
11262 element.automaticTotalDiscount();
11263 SalesTotals::showTaxLine(menuitemDisplayStr(TaxTmpWorkSalesOrder), salesTable,salesLine,element);
11264 }
11265
11266 }
11267
11268 [Control("MenuButton")]
11269 class ButtonLineInventorySMB
11270 {
11271 void clicked()
11272 {
11273 // Don't allow inventory reservation for continuity items
11274 if (mcrSalesLine.ContinuityScheduleId)
11275 {
11276 buttonLineInventReservation.enabled (false);
11277 }
11278
11279 if (buttonLineInventTrans.visible() &&
11280 buttonLineInventTrans.enabled())
11281 {
11282 buttonLineInventTransGoodsInRoute_RU.visible(salesLine.hasInventTransGoodsInRoute_RU());
11283 }
11284
11285 super();
11286 }
11287
11288 }
11289
11290 [Control("Image")]
11291 class lineDeliveryType
11292 {
11293 public str toolTip()
11294 {
11295 DictEnum dictEnum = new DictEnum(enumNum(LineDeliveryType));
11296
11297 return dictEnum.label() + ': ' + dictEnum.value2Name(salesLine.LineDeliveryType);
11298 }
11299
11300 }
11301
11302 [Control("String")]
11303 class SalesLine_ItemId
11304 {
11305 public void gotFocus()
11306 {
11307 // Display any messages associated with the item.
11308 element.mcrDisplayItemMessage();
11309 super();
11310 }
11311
11312 public boolean modified()
11313 {
11314 boolean ret;
11315 boolean recordsCreated;
11316 EcoResProductRecId productRecId;
11317
11318 if (element.isMCRInventSearchEnabled())
11319 {
11320 [productRecId, recordsCreated] = MCRInventSearch::searchProduct(salesLine, salesLine_ItemId.text());
11321
11322 // DataSource ItemId.modified() is called on the MCRSalesQuickQuoteForm, if a product is returned then
11323 // it means the line was not updated there, so set ItemId and update product dimensions based on returned product.
11324 if (productRecId)
11325 {
11326 InventDistinctProduct distinctProduct = InventDistinctProduct::findByProduct(productRecId);
11327 ItemId newItemId = distinctProduct ? distinctProduct.ItemId : InventTable::findByProduct(productRecId).ItemId;
11328 // If the user entered an item ID, skip refresh
11329 if (newItemId != salesLine_ItemId.text())
11330 {
11331 salesLine.ItemId = newItemId;
11332 salesLine_ds.refresh();
11333 }
11334
11335 element.setProductFromLookup(distinctProduct);
11336
11337 ret = super();
11338 }
11339 else
11340 {
11341 ret = recordsCreated;
11342 }
11343 }
11344 else
11345 {
11346 ret = super();
11347 }
11348
11349 if (mcrCallCenterOrder)
11350 {
11351 element.mcrSetLineControls();
11352 }
11353
11354 return ret;
11355 }
11356
11357 public str resolveAmbiguousReference()
11358 {
11359 return this.text();
11360 }
11361
11362 }
11363
11364 [Control("String")]
11365 class SalesLine_W_RefInvoiceId_MY
11366 {
11367 public void lookup()
11368 {
11369 element.performCustInvoiceJourLookup_MY(
11370 this,
11371 queryValue(RefNum::SalesOrder) + "," + queryValue(RefNum::Project),
11372 salesTable.CustAccount);
11373 }
11374
11375 public boolean modified()
11376 {
11377 boolean ret;
11378
11379 ret = super();
11380
11381 if (ret)
11382 {
11383 if (this.text())
11384 {
11385 element.updateSourceRefControlsAfterLookup_MY();
11386 }
11387 }
11388
11389 return ret;
11390 }
11391
11392 }
11393
11394 [Control("ComboBox")]
11395 class SalesLineReturnDetails_IN_Type
11396 {
11397 public boolean modified()
11398 {
11399 boolean ret;
11400 ret = super();
11401 // <GIN>
11402 element.updateReturnableDetails_IN();
11403 // </GIN>
11404 return ret;
11405 }
11406
11407 }
11408
11409 [Control("ComboBox")]
11410 class SalesLineReturnDetails_IN_BasisType
11411 {
11412 public boolean modified()
11413 {
11414 boolean ret;
11415 ret = super();
11416 element.setBasisDate_IN();
11417 return ret;
11418 }
11419
11420 }
11421
11422 [Control("Integer")]
11423 class GroupCustomerReturnPeriod_Period
11424 {
11425 public boolean modified()
11426 {
11427 boolean ret;
11428
11429 ret = super();
11430 salesLineReturnDetails_IN_ds.write();
11431
11432 return ret;
11433 }
11434
11435 }
11436
11437 [Control("ComboBox")]
11438 class GroupCustomerReturnPeriod_PeriodType
11439 {
11440 public boolean modified()
11441 {
11442 boolean ret;
11443
11444 ret = super();
11445 salesLineReturnDetails_IN_ds.write();
11446
11447 return ret;
11448 }
11449
11450 }
11451
11452 [Control("String")]
11453 class MCRSalesLine_GiftCardNumber
11454 {
11455 public boolean modified()
11456 {
11457 boolean ret;
11458
11459 ret = super();
11460
11461 if (ret)
11462 {
11463 MCRSalesLine_ds.giftCardPolicyChanged();
11464 }
11465
11466 return ret;
11467 }
11468
11469 }
11470
11471 [Control("MenuFunctionButton")]
11472 class SalesAvailableDlvDatesLine
11473 {
11474 void clicked()
11475 {
11476 salesLine_ds.updateExplosionCTP();
11477
11478 super();
11479 }
11480
11481 }
11482
11483 [Control("String")]
11484 class SalesLineDeliveryGroup_DlvMode
11485 {
11486 public boolean validate()
11487 {
11488 boolean ret = true;
11489 LogisticsPostalAddress dlvAddress;
11490
11491 dlvAddress = LogisticsPostalAddress::findRecId(SalesTable.DeliveryPostalAddress);
11492
11493 if (dlvAddress &&
11494 RetailDlvModeAddressLine::isAddressExcluded(dlvAddress.CountryRegionId, dlvAddress.State, this.text()))
11495 {
11496 ret = checkFailed(strFmt("@Retail:MCRDlvModeAddressError", SalesLine.ItemId));
11497 }
11498
11499 return ret;
11500 }
11501
11502 }
11503
11504 [Control("String")]
11505 class TMSCarrierInfo_CarrierCode
11506 {
11507 /// <summary>
11508 /// Open the TMSCarrier form to display the details of the carrier displayed in the TMSCarrierInfo_CarrierCode control.
11509 /// </summary>
11510 public void jumpRef()
11511 {
11512 TMSCarrier::jumpRefCarrierCode(this.valueStr());
11513 }
11514
11515 }
11516
11517 [Control("String")]
11518 class RetailSalesLine_PriceOverrideReasonCode
11519 {
11520 public void lookup()
11521 {
11522 // lookup logic in datafield PriceOverrideReasonCode
11523 super();
11524 }
11525
11526 }
11527
11528 [Control("String")]
11529 class GroupCreditNote_ReasonCode
11530 {
11531 public void lookup()
11532 {
11533 ReasonFormTable::reasonCodeLookup(
11534 this,
11535 LedgerJournalACType::Cust,
11536 LedgerJournalACType::Cust,
11537 false,
11538 false,
11539 LedgerJournalACType::Cust,
11540 true);
11541 }
11542
11543 /// <summary>
11544 /// Redraws the form as the reason code field is modified.
11545 /// </summary>
11546 /// <returns>
11547 /// A Boolean indicating whether the field is modified or not.
11548 /// </returns>
11549 public boolean modified()
11550 {
11551 boolean ret;
11552 ret = super();
11553 salesLine_DS.cacheCalculateMethod(tableMethodStr(SalesLine,editReasonCode));
11554 salesLine_DS.cacheCalculateMethod(tableMethodStr(SalesLine,editReasonComment));
11555 return ret;
11556 }
11557
11558 }
11559
11560 [Control("String")]
11561 class GroupCreditNote_ReasonComment
11562 {
11563 public boolean modified()
11564 {
11565 boolean ret;
11566
11567 ret = super();
11568 salesLine_DS.cacheCalculateMethod(tableMethodStr(SalesLine,editReasonComment));
11569 return ret;
11570 }
11571
11572 }
11573
11574 [Control("ComboBox")]
11575 class SalesTable_SalesType
11576 {
11577 public boolean modified()
11578 {
11579 boolean ret;
11580
11581 ret = super();
11582 element.changeType();
11583 return ret;
11584 }
11585
11586 }
11587
11588 [Control("String")]
11589 class editContactPersonName1
11590 {
11591 public void jumpRef()
11592 {
11593 salesTable_ContactPersonId.jumpRef();
11594 }
11595
11596 void lookup()
11597 {
11598 ContactPerson::lookupCustContactPerson(salesTable_ContactPersonId,
11599 salesTable.CustAccount,
11600 editContactPersonName1,
11601 salesTable.ContactPersonId);
11602 }
11603
11604 }
11605
11606 [Control("String")]
11607 class References_ReasonCode
11608 {
11609 public void lookup()
11610 {
11611 ReasonFormTable::reasonCodeLookup(
11612 this,
11613 LedgerJournalACType::Cust,
11614 LedgerJournalACType::Cust,
11615 false,
11616 false,
11617 LedgerJournalACType::Cust,
11618 true);
11619 }
11620
11621 public boolean modified()
11622 {
11623 boolean ret = super();
11624
11625 // Update the cache for the ReasonComment value, which is changed during the call to super.
11626 salesTable_DS.cacheCalculateMethod(tableMethodStr(SalesTable, editReasonComment));
11627
11628 if (salesLine.RecId)
11629 {
11630 if (element.confirmReasonCodeUpdateOnLines())
11631 {
11632 salesTable.updateLineReasonCode();
11633 }
11634
11635 salesLine_ds.reread();
11636 references_ReasonComment.modified();
11637 }
11638
11639 return ret;
11640 }
11641
11642 }
11643
11644 [Control("String")]
11645 class References_ReasonComment
11646 {
11647 public boolean modified()
11648 {
11649 boolean ret = super();
11650
11651 if (salesLine.RecId)
11652 {
11653 if (element.confirmReasonCommentUpdateOnLines())
11654 {
11655 salesTable.updateLineReasonComment();
11656 }
11657
11658 salesLine_ds.reread();
11659 }
11660
11661 return ret;
11662 }
11663
11664 }
11665
11666 [Control("String")]
11667 class Format_MY_M_editInvoiceType_MY
11668 {
11669 public void lookup()
11670 {
11671 TaxGSTDocInvoiceType_MY::construct(tableNum(SalesTable_W)).lookup(this);
11672 }
11673
11674 }
11675
11676 [Control("String")]
11677 class Delivery_DlvMode
11678 {
11679 public boolean validate()
11680 {
11681 boolean ret = true;
11682 LogisticsPostalAddress dlvAddress;
11683
11684 dlvAddress = LogisticsPostalAddress::findRecId(SalesTable.DeliveryPostalAddress);
11685
11686 if (dlvAddress &&
11687 RetailDlvModeAddressLine::isAddressExcluded(dlvAddress.CountryRegionId, dlvAddress.State, this.text()))
11688 {
11689 ret = checkFailed(strFmt("@Retail:MCRDlvModeAddressError", SalesLine.ItemId));
11690 }
11691
11692 return ret;
11693 }
11694
11695 }
11696
11697 [Control("String")]
11698 class TMSSalesTable_CarrierServiceCode
11699 {
11700 public void lookup()
11701 {
11702 TMSCarrierService::lookupCarrierServiceCode(this, tmsSalesTable.CarrierCode);
11703 }
11704
11705 }
11706
11707 [Control("String")]
11708 class TMSSalesTable_CarrierGroupCode
11709 {
11710 public boolean modified()
11711 {
11712 boolean ret;
11713
11714 if (tmsSalesTable.RecId == 0)
11715 {
11716 tmsSalesTable.initFromSalesTable(salesTable.SalesId);
11717 }
11718
11719 ret = super();
11720
11721 element.enableTMSFields();
11722
11723 return ret;
11724 }
11725
11726 }
11727
11728 [Control("String")]
11729 class TMSSalesTable_RouteConfigCode
11730 {
11731 public boolean modified()
11732 {
11733 boolean ret;
11734
11735 if (tmsSalesTable.RecId == 0)
11736 {
11737 tmsSalesTable.initFromSalesTable(salesTable.SalesId);
11738 }
11739
11740 ret = super();
11741
11742 element.enableTMSFields();
11743
11744 return ret;
11745 }
11746
11747 }
11748
11749 [Control("String")]
11750 class TMSSalesTable_TransportationTemplateId
11751 {
11752 public boolean modified()
11753 {
11754 boolean ret;
11755
11756 if (tmsSalesTable.RecId == 0)
11757 {
11758 tmsSalesTable.initFromSalesTable(salesTable.SalesId);
11759 }
11760
11761 ret = super();
11762
11763 element.enableTMSFields();
11764
11765 return ret;
11766 }
11767
11768 }
11769
11770 [Control("String")]
11771 class Payment_Payment
11772 {
11773 public boolean leave()
11774 {
11775 boolean ok = super();
11776
11777 if (ok && salesTable.CreditCardCustRefId == 0 && payment_M_editCreditCard.text())
11778 {
11779 // Clears the credit card number if the payment type is not a credit card
11780 salesTable_ds.cacheCalculateMethod(payment_M_editCreditCard.dataMethod());
11781 }
11782
11783 return ok;
11784 }
11785
11786 }
11787
11788 [Control("Date")]
11789 class Payment_FixedDueDate
11790 {
11791 public void enter()
11792 {
11793 super();
11794
11795 priorDueDate = this.dateValue();
11796 }
11797
11798 }
11799
11800 [Control("String")]
11801 class Payment_M_editCreditCard
11802 {
11803 public void lookup()
11804 {
11805 if (salesTable.payment().CreditCardPaymentType == CreditCardPaymentType::CreditCard)
11806 {
11807 CreditCardCust::lookupCreditCard(this, salesTable.InvoiceAccount, salesTable.CreditCardCustRefId);
11808 }
11809 }
11810
11811 public boolean modified()
11812 {
11813 boolean isOK = super();
11814
11815 element.enableHeaderCreditCardMenuItems();
11816
11817 return isOK;
11818 }
11819
11820 }
11821
11822 [Control("Date")]
11823 class Payment_CashDiscBaseDate
11824 {
11825 public boolean modified()
11826 {
11827 boolean ret = super();
11828
11829 CustPaymSched custPaymSched = CustPaymSched::find(salesTable.TableId, salesTable.RecId);
11830
11831 if (custPaymSched && custPaymSched.CopyPreciselyToInvoice)
11832 {
11833 warning("@AccountsReceivable:PaymSchedForSalesOrderHasBeenCreated");
11834 }
11835
11836 return ret;
11837 }
11838
11839 }
11840
11841 [Control("ReferenceGroup")]
11842 class Payment_DirectDebitMandate
11843 {
11844 public Common lookupReference()
11845 {
11846 return CustDirectDebitMandate::lookupReference(
11847 salesTable.InvoiceAccount,
11848 this);
11849 }
11850
11851 public Common resolveReference()
11852 {
11853 return CustDirectDebitMandate::resolveReference(
11854 salesTable.InvoiceAccount,
11855 this);
11856 }
11857
11858 }
11859
11860 [Control("ComboBox")]
11861 class SalesTable_SalesTypeGrid
11862 {
11863 public boolean modified()
11864 {
11865 boolean ret;
11866
11867 ret = super();
11868 element.changeType();
11869 return ret;
11870 }
11871
11872 }
11873
11874}