Ejemplo n.º 1
0
        protected virtual void TaxReportLine_SortOrder_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            VendorMaster  taxVendor    = TaxVendor.Current;
            TaxReportLine reportLine   = (TaxReportLine)e.Row;
            int?          newSortOrder = e.NewValue as int?;

            if (reportLine == null || reportLine.TempLineNbr != null || taxVendor == null || taxVendor.ShowNoTemp == true ||
                reportLine.SortOrder == newSortOrder)
            {
                return;
            }

            if (newSortOrder == null || newSortOrder <= 0)
            {
                string errorMsg = newSortOrder == null
                                        ? Common.Messages.MustHaveValue
                                        : Common.Messages.ShouldBePositive;

                throw new PXSetPropertyException(errorMsg, nameof(TaxReportLine.SortOrder));
            }

            bool alreadyExists = ReportLine.Select()
                                 .RowCast <TaxReportLine>()
                                 .Any(line => line.SortOrder.Value == newSortOrder);

            if (alreadyExists)
            {
                throw new PXSetPropertyException(Messages.SortOrderNumbersMustBeUnique);
            }
        }
        protected virtual void VendorMaster_RowSelecting(PXCache sender, PXRowSelectingEventArgs e)
        {
            VendorMaster vendorMaster = e.Row as VendorMaster;

            if (vendorMaster != null && vendorMaster.ShowNoTemp == null)
            {
                vendorMaster.ShowNoTemp = false;
            }
        }
        protected override void OnRowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            TaxReportLine insertedLine = e.Row as TaxReportLine;
            VendorMaster  vendorMaster = taxReportGraph.TaxVendor.Current;

            if (vendorMaster == null || insertedLine == null || insertedLine.SortOrder != null)
            {
                return;
            }

            List <TaxReportLine> taxLines = Select().RowCast <TaxReportLine>()
                                            .Where(line => line.SortOrder.HasValue)
                                            .ToList();

            insertedLine.SortOrder = taxLines.Count > 0
                                ? taxLines.Max(line => line.SortOrder) + 1
                                : insertedLine.LineNbr;
        }
        private void RenumberDetailTaxLines(IList <TaxReportLine> betweenLines, IList <TaxReportLine> movedLines)
        {
            VendorMaster vendorMaster = taxReportGraph.TaxVendor.Current;

            if (vendorMaster == null)
            {
                return;
            }

            Dictionary <int, TaxReportLine> mainLines = betweenLines.Concat(movedLines)
                                                        .Where(line => line.TempLineNbr == null && line.TempLine == true)
                                                        .ToDictionary(line => line.LineNbr.Value);

            if (mainLines.Count == 0)
            {
                return;
            }

            var detailLinesGroupedByMainLines =
                PXSelect <TaxReportLine,
                          Where <TaxReportLine.vendorID, Equal <Required <VendorMaster.bAccountID> >,
                                 And <TaxReportLine.tempLineNbr, IsNotNull,
                                      And <TaxReportLine.tempLineNbr, In <Required <TaxReportLine.tempLineNbr> > > > > >
                .Select(taxReportGraph, vendorMaster.BAccountID, mainLines.Keys.ToArray())
                .RowCast <TaxReportLine>()
                .GroupBy(line => line.TempLineNbr.Value);

            foreach (var detailLinesGroup in detailLinesGroupedByMainLines)
            {
                TaxReportLine mainLine;

                if (!mainLines.TryGetValue(detailLinesGroup.Key, out mainLine))
                {
                    continue;
                }

                foreach (TaxReportLine detailLine in detailLinesGroup)
                {
                    detailLine.SortOrder = mainLine.SortOrder;
                    Cache.SmartSetStatus(detailLine, PXEntryStatus.Updated);
                }
            }
        }
Ejemplo n.º 5
0
        private string ReloadTaxReportLinesForTaxZonesInternalAndPrepareChangesDescription()
        {
            VendorMaster vendor = taxReportGraph?.TaxVendor.Current;

            if (vendor == null)
            {
                return(null);
            }

            Dictionary <int, TaxReportLine> templateLinesByLineNumber =
                PXSelect <TaxReportLine,
                          Where <TaxReportLine.vendorID, Equal <Required <VendorMaster.bAccountID> >,
                                 And <TaxReportLine.tempLineNbr, IsNull,
                                      And <TaxReportLine.tempLine, Equal <True> > > > >
                .Select(taxReportGraph, vendor.BAccountID)
                .RowCast <TaxReportLine>()
                .ToDictionary(line => line.LineNbr.Value);

            if (templateLinesByLineNumber.Count == 0)
            {
                return(PXLocalizer.Localize(Messages.NoLinesByTaxZone, typeof(TX.Messages).FullName));
            }

            Dictionary <string, TaxZone> zonesInSystem = PXSelect <TaxZone> .Select(taxReportGraph)
                                                         .RowCast <TaxZone>()
                                                         .ToDictionary(zone => zone.TaxZoneID);

            ILookup <int, TaxReportLine> detailLinesByTemplateLineNumber =
                PXSelect <TaxReportLine,
                          Where <TaxReportLine.vendorID, Equal <Required <VendorMaster.bAccountID> >,
                                 And <TaxReportLine.tempLineNbr, IsNotNull> > >
                .Select(taxReportGraph, vendor.BAccountID)
                .RowCast <TaxReportLine>()
                .ToLookup(line => line.TempLineNbr.Value);


            List <TaxReportLine> deletedLines = DeleteChildTaxLinesForOldZones(zonesInSystem, detailLinesByTemplateLineNumber);
            List <TaxReportLine> addedLines   = GenerateChildTaxLinesForMissingZones(templateLinesByLineNumber, zonesInSystem,
                                                                                     detailLinesByTemplateLineNumber);

            return(GetTextFromReloadTaxZonesResult(addedLines, deletedLines));
        }