protected virtual void VerifyTaxID(TaxTotal row, bool externalCall)
        {
            bool nomatch = false;

            //TODO: move details to parameter

            foreach (Detail det in Details.Select())
            {
                ITaxDetail taxzonedet = MatchesCategory(det, (TaxItem)row);
                AddOneTax(det, taxzonedet);
            }
            object originalRow = TaxTotals.Cache.GetMain(row);

            _NoSumTotals      = (CurrentDocument.TaxCalc == TaxCalc.ManualCalc && row.TaxRate != 0m && externalCall == false);
            PXRowDeleting del = delegate(PXCache _sender, PXRowDeletingEventArgs _e) { nomatch |= ReferenceEquals(originalRow, _e.Row); };

            Base.RowDeleting.AddHandler(originalRow.GetType(), del);
            try
            {
                CalcTaxes(null);
            }
            finally
            {
                Base.RowDeleting.RemoveHandler(originalRow.GetType(), del);
            }
            _NoSumTotals = false;

            if (nomatch)
            {
                TaxTotals.Cache.RaiseExceptionHandling <TaxTotal.refTaxID>(row, row.RefTaxID,
                                                                           new PXSetPropertyException(Messages.NoLinesMatchTax, PXErrorLevel.RowError));
            }
            TaxTotals.Cache.Current = row;
        }
Esempio n. 2
0
		protected virtual void VerifyTaxID(PXCache sender, object row, bool externalCall)
		{
			bool nomatch = false;
			PXCache cache = sender.Graph.Caches[_ChildType];
			PXCache taxcache = sender.Graph.Caches[_TaxType];

			//TODO: move details to parameter
			List<object> details = ChildSelect(cache, row);
			foreach (object det in details)
			{
				ITaxDetail taxzonedet = MatchesCategory(cache, det, (ITaxDetail)row);
				AddOneTax(taxcache, det, taxzonedet);
			}
			_NoSumTotals = (_TaxCalc == TaxCalc.ManualCalc && ((TaxDetail)row).TaxRate != 0m && externalCall == false);
			PXRowDeleting del = delegate (PXCache _sender, PXRowDeletingEventArgs _e) { nomatch |= object.ReferenceEquals(row, _e.Row); };
			sender.Graph.RowDeleting.AddHandler(_TaxSumType, del);
			try
			{
				CalcTaxes(cache, null);
			}
			finally
			{
				sender.Graph.RowDeleting.RemoveHandler(_TaxSumType, del);
			}
			_NoSumTotals = false;

			if (nomatch)
			{
				sender.RaiseExceptionHandling("TaxID", row, ((TaxDetail)row).TaxID, new PXSetPropertyException(TX.Messages.NoLinesMatchTax, PXErrorLevel.RowError));
			}
			sender.Current = row;
		}