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 RowDeleted event handler for the <see cref="Discount" /> mapped cache extension.</summary>
        /// <param name="e">Parameters of the event.</param>
        protected virtual void _(Events.RowDeleted <Discount> e)
        {
            if (!DiscountEngineGraph.IsInternalDiscountEngineCall && e.Row != null)
            {
                DiscountEngineGraph.UpdateDocumentDiscount(Details.Cache, Details, Discounts, Documents.Current.BranchID, Documents.Current.LocationID ?? 0, Documents.Current.DocumentDate, (e.Row.Type != null && e.Row.Type != DiscountType.Document && e.Row.Type != DiscountType.ExternalDocument), DiscountEngine.DefaultARDiscountCalculationParameters);
                (Discounts.Cache as PXModelExtension <Discount>)?.UpdateExtensionMapping(e.Row);
            }

            RefreshTotalsAndFreeItems(Discounts.Cache);
        }