private void distributePercentOf(TermsInstallments row) { if (row != null && row.InstPercent.HasValue && row.InstPercent != null) { //Find last TermsInstallments lastRow = null; foreach (TermsInstallments it in this.Installments.Select()) { if (object.ReferenceEquals(it, row)) { continue; } if (lastRow == null || (it.InstallmentNbr.HasValue && it.InstallmentNbr.Value > lastRow.InstallmentNbr)) { lastRow = it; } } if (lastRow != null) { lastRow.InstPercent += row.InstPercent; row.InstPercent = 0; this.Installments.Cache.Update(lastRow); } } }
protected virtual void TermsInstallments_RowInserting(PXCache cache, PXRowInsertingEventArgs e) { TermsInstallments record = (TermsInstallments)e.Row; short lastID = 0; if (!record.InstallmentNbr.HasValue || record.InstallmentNbr.Value == 0) { //record.InstPercent = 100; foreach (TermsInstallments it in this.Installments.Select()) { if (object.ReferenceEquals(it, record)) { continue; } if (it.InstallmentNbr.HasValue && it.InstallmentNbr.Value > lastID) { lastID = it.InstallmentNbr.Value; } //record.InstPercent -= it.InstPercent; } lastID++; //IncrementID record.InstallmentNbr = lastID; this.justInserted = record.InstallmentNbr; /*if (record.InstPercent <= 0) * { * throw new PXException(Messages.ListOfInstallmentsComplete); * }*/ } else { this.justInserted = null; } }
protected virtual void TermsInstallments_InstPercent_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e) { TermsInstallments record = (TermsInstallments)e.Row; Decimal? percent = 100; foreach (TermsInstallments it in this.Installments.Select()) { if (object.ReferenceEquals(it, record)) { continue; } percent -= it.InstPercent; } record.InstPercent = percent; }
protected virtual void TermsInstallments_RowDeleted(PXCache cache, PXRowDeletedEventArgs e) { TermsInstallments row = (TermsInstallments)e.Row; if (!this.isMassDelete) { Terms term = this.TermsDef.Current; term.InstallmentCntr--; if (!(this.justInserted.HasValue && this.justInserted.Value == row.InstallmentNbr)) { this.distributePercentOf(row); this.Installments.View.RequestRefresh(); } this.TermsDef.Cache.Update(term); } }