Exemplo n.º 1
0
        private void ValidateDocDate(PXCache cache, TaxAdjustment doc)
        {
            if (doc.DocDate == null || doc.TaxPeriod == null || doc.BranchID == null)
            {
                return;
            }

            var taxPeriod = TaxYearMaint.FindTaxPeriodByKey(this,
                                                            PXAccess.GetMasterBranchID(doc.BranchID).First(),
                                                            doc.VendorID,
                                                            doc.TaxPeriod);

            if (taxPeriod == null)
            {
                return;
            }

            string errorMessage = null;

            if (vendor.Current.TaxReportFinPeriod == true)
            {
                var finPeriod = FinPeriodIDAttribute.GetByID(this, doc.FinPeriodID);

                if (finPeriod.FinDate >= taxPeriod.EndDate)
                {
                    errorMessage = Messages.SelectedDateBelongsToTheTaxPeriodThatIsGreaterThanTheSpecifiedOne;
                }
            }
            else if (doc.DocDate >= taxPeriod.EndDate)
            {
                errorMessage = Messages.SelectedDateBelongsToTheTaxPeriodThatIsGreaterThanTheSpecifiedOne;
            }

            var ex = errorMessage != null
                                ? new PXSetPropertyException(errorMessage, PXErrorLevel.Warning)
                                : null;

            cache.RaiseExceptionHandling <TaxAdjustment.docDate>(doc, doc.DocDate, ex);
        }
Exemplo n.º 2
0
 public FinPeriod GetFinPeriodByID(PXGraph graph, string financialPeriodID)
 {
     return(FinPeriodIDAttribute.GetByID(graph, financialPeriodID));
 }