protected void CheckUnique(PXCache cache, TaxBucketLine bucketLine) { var dataRowWithSameLineNbr = PXSelectJoin <TaxBucketLine, InnerJoin <TaxReportLine, On <TaxReportLine.vendorID, Equal <TaxBucketLine.vendorID>, And <TaxReportLine.lineNbr, Equal <TaxBucketLine.lineNbr> > > >, Where <TaxBucketLine.vendorID, Equal <Current <TaxBucketMaster.vendorID> >, And <TaxBucketLine.bucketID, Equal <Current <TaxBucketMaster.bucketID> >, And <TaxReportLine.tempLineNbr, IsNull, And <TaxBucketLine.lineNbr, Equal <Required <TaxBucketLine.lineNbr> > > > > > > .Select(this, bucketLine.LineNbr).AsEnumerable() .Cast <PXResult <TaxBucketLine, TaxReportLine> >() .ToArray(); if (dataRowWithSameLineNbr.Any()) { var reportLine = (TaxReportLine)dataRowWithSameLineNbr.First(); var bucket = (TaxBucket)PXSelect <TaxBucket, Where <TaxBucket.vendorID, Equal <Current <TaxBucketMaster.vendorID> >, And <TaxBucket.bucketID, Equal <Current <TaxBucketMaster.bucketID> > > > > .Select(this); throw new PXException(Messages.TheReportingGroupAlreadyContainsTheReportLine, bucket.Name, reportLine.Descr); } }
private void SyncReportLinesAndBucketLines() { TaxBucketLine_Vendor_LineNbr.Cache.Clear(); foreach (var reportLine in ReportLine.Cache.Inserted.RowCast <TaxReportLine>()) { var parentBuckets = TaxBucketLine_Vendor_LineNbr.Select(reportLine.VendorID, reportLine.TempLineNbr).RowCast <TaxBucketLine>(); foreach (var bucketLine in parentBuckets) { TaxBucketLine newBucketLine = PXCache <TaxBucketLine> .CreateCopy(bucketLine); newBucketLine.LineNbr = reportLine.LineNbr; TaxBucketLine_Vendor_LineNbr.Cache.Insert(newBucketLine); } } foreach (var reportLine in ReportLine.Cache.Deleted.RowCast <TaxReportLine>()) { var bucketLinesToDelete = TaxBucketLine_Vendor_LineNbr.Select(reportLine.VendorID, reportLine.LineNbr); foreach (var bucketLine in bucketLinesToDelete) { TaxBucketLine_Vendor_LineNbr.Cache.Delete(bucketLine); } } }
protected virtual void TaxBucketLine_RowInserted(PXCache sender, PXRowInsertedEventArgs e) { foreach (PXResult <TaxReportLine, TaxBucketLine> res in PXSelectJoin <TaxReportLine, LeftJoin <TaxBucketLine, On <TaxBucketLine.vendorID, Equal <TaxReportLine.vendorID>, And <TaxBucketLine.lineNbr, Equal <TaxReportLine.lineNbr> > > >, Where <TaxReportLine.vendorID, Equal <Required <TaxReportLine.vendorID> >, And <TaxReportLine.tempLineNbr, Equal <Required <TaxReportLine.tempLineNbr> > > > > .Select(this, ((TaxBucketLine)e.Row).VendorID, ((TaxBucketLine)e.Row).LineNbr)) { TaxBucketLine new_bucket = PXCache <TaxBucketLine> .CreateCopy((TaxBucketLine)e.Row); new_bucket.LineNbr = ((TaxReportLine)res).LineNbr; BucketLine.Cache.Insert(new_bucket); } BucketLine.Cache.Current = e.Row; }
protected virtual void TaxReportLine_RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Insert && ((TaxReportLine)e.Row).TempLineNbr != null) { //select parent buckets foreach (TaxBucketLine bucket in TaxBucketLine_Vendor_LineNbr.Select(((TaxReportLine)e.Row).VendorID, ((TaxReportLine)e.Row).TempLineNbr)) { TaxBucketLine new_bucket = PXCache <TaxBucketLine> .CreateCopy(bucket); new_bucket.LineNbr = ((TaxReportLine)e.Row).LineNbr; TaxBucketLine_Vendor_LineNbr.Cache.Insert(new_bucket); } } if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Delete) { //select own buckets foreach (TaxBucketLine bucket in TaxBucketLine_Vendor_LineNbr.Select(((TaxReportLine)e.Row).VendorID, ((TaxReportLine)e.Row).LineNbr)) { TaxBucketLine_Vendor_LineNbr.Cache.Delete(bucket); } } }
private void calcOccurances(bool CalcWithZones) { if (!CalcWithZones) { _vendorBucketLines.WhereAnd <Where <TaxReportLine.tempLineNbr, IsNull> >(); } PXResultset <TaxBucketLine> BucketLineTaxAmt = _vendorBucketLines.Select(_bAccountID, _taxLineType); if (BucketLineTaxAmt == null) { _bucketsDict = null; return; } _bucketsDict = new Dictionary <int, List <int> >(); foreach (PXResult <TaxBucketLine> bucketLineSet in BucketLineTaxAmt) { TaxBucketLine bucketLine = (TaxBucketLine)bucketLineSet[typeof(TaxBucketLine)]; TaxReportLine reportLine = (TaxReportLine)bucketLineSet[typeof(TaxReportLine)]; if (bucketLine.BucketID != null && reportLine.LineNbr != null) { if (!_bucketsDict.ContainsKey((int)bucketLine.BucketID)) { _bucketsDict[(int)bucketLine.BucketID] = new List <int>(); } _bucketsDict[(int)bucketLine.BucketID].Add((int)bucketLine.LineNbr); } } List <int> bucketsList = _bucketsDict.Keys.ToList <int>(); for (int i = 0; i < bucketsList.Count; i++) { for (int j = i + 1; j < bucketsList.Count; j++) { if (_bucketsDict[bucketsList[i]].Count == _bucketsDict[bucketsList[j]].Count && IsSubList(_bucketsDict[bucketsList[i]], _bucketsDict[bucketsList[j]])) { _bucketsDict.Remove(bucketsList[i]); break; } } } _bucketLinesOccurence = new Dictionary <int, int>(); _bucketsLinesPairs = new Dictionary <int, Dictionary <int, int> >(); foreach (KeyValuePair <int, List <int> > kvp in _bucketsDict) { foreach (int lineNbr in kvp.Value) { if (!_bucketLinesOccurence.ContainsKey(lineNbr)) { _bucketLinesOccurence[lineNbr] = 0; } _bucketLinesOccurence[lineNbr]++; } for (int i = 0; i < kvp.Value.Count - 1; i++) { for (int j = i + 1; j < kvp.Value.Count; j++) { int key; int value; if (kvp.Value[i] < kvp.Value[j]) { key = kvp.Value[i]; value = kvp.Value[j]; } else { key = kvp.Value[j]; value = kvp.Value[i]; } if (!_bucketsLinesPairs.ContainsKey(key)) { _bucketsLinesPairs[key] = new Dictionary <int, int>(); } if (!_bucketsLinesPairs[key].ContainsKey(value)) { _bucketsLinesPairs[key][value] = 0; } _bucketsLinesPairs[key][value]++; } } } }