Esempio n. 1
0
        /// <summary>The RowUpdated event handler for the <see cref="Discount" /> mapped cache extension.</summary>
        /// <param name="e">Parameters of the event.</param>
        protected virtual void _(Events.RowUpdated <Discount> e)
        {
            if (!DiscountEngineGraph.IsInternalDiscountEngineCall && e.Row != null)
            {
                if (!Discounts.Cache.ObjectsEqual <Discount.skipDiscount>(e.Row, e.OldRow))
                {
                    DiscountEngineGraph.UpdateDocumentDiscount(Details.Cache, Details, Discounts, Documents.Current.BranchID, Documents.Current.LocationID ?? 0, Documents.Current.DocumentDate, e.Row.Type != DiscountType.Document, DiscountEngine.DefaultARDiscountCalculationParameters);
                    RefreshTotalsAndFreeItems(Discounts.Cache);
                    (Discounts.Cache as PXModelExtension <Discount>)?.UpdateExtensionMapping(e.Row);
                }
                if (!Discounts.Cache.ObjectsEqual <Discount.discountID>(e.Row, e.OldRow) || !Discounts.Cache.ObjectsEqual <Discount.discountSequenceID>(e.Row, e.OldRow))
                {
                    e.Row.IsManual = true;
                    DiscountEngineGraph.InsertManualDocGroupDiscount(Details.Cache, Details, Discounts, e.Row, e.Row.DiscountID, Discounts.Cache.ObjectsEqual <Discount.discountID>(e.Row, e.OldRow) ? e.Row.DiscountSequenceID : null,
                                                                     Documents.Current.BranchID, Documents.Current.LocationID ?? 0, Documents.Current.DocumentDate, DiscountEngine.DefaultARDiscountCalculationParameters);
                    RefreshTotalsAndFreeItems(Discounts.Cache);
                    (Discounts.Cache as PXModelExtension <Discount>)?.UpdateExtensionMapping(e.Row);
                }

                if (DiscountEngineGraph.SetExternalManualDocDiscount(Details.Cache, Details, Discounts, e.Row, e.OldRow, DiscountEngine.DefaultARDiscountCalculationParameters))
                {
                    RefreshTotalsAndFreeItems(Discounts.Cache);
                    (Discounts.Cache as PXModelExtension <Discount>)?.UpdateExtensionMapping(e.Row);
                }
            }
        }
Esempio n. 2
0
        /// <summary>The RowInserted event handler for the <see cref="Discount" /> mapped cache extension.</summary>
        /// <param name="e">Parameters of the event.</param>
        protected virtual void _(Events.RowInserted <Discount> e)
        {
            if (!DiscountEngineGraph.IsInternalDiscountEngineCall && e.Row != null)
            {
                if (e.Row.DiscountID != null)
                {
                    DiscountEngineGraph.InsertManualDocGroupDiscount(Details.Cache, Details, Discounts, e.Row, e.Row.DiscountID, null,
                                                                     Documents.Current.BranchID, Documents.Current.LocationID ?? 0, Documents.Current.DocumentDate, DiscountEngine.DefaultARDiscountCalculationParameters);
                    RefreshTotalsAndFreeItems(Discounts.Cache);
                    (Discounts.Cache as PXModelExtension <Discount>)?.UpdateExtensionMapping(e.Row);
                }

                if (DiscountEngineGraph.SetExternalManualDocDiscount(Details.Cache, Details, Discounts, e.Row, null, DiscountEngine.DefaultARDiscountCalculationParameters))
                {
                    RefreshTotalsAndFreeItems(Discounts.Cache);
                    (Discounts.Cache as PXModelExtension <Discount>)?.UpdateExtensionMapping(e.Row);
                }
            }
        }