protected virtual PXSetPropertyException CanBeLinkDeleted(OrganizationLedgerLink link) { Ledger ledger = GeneralLedgerMaint.FindLedgerByID(Base, link.LedgerID); if (ledger.BalanceType == LedgerBalanceType.Actual) { if (GLUtility.RelatedGLHistoryExists(Base, link.LedgerID, link.OrganizationID)) { Organization org = OrganizationMaint.FindOrganizationByID(Base, link.OrganizationID, true); return(new PXSetPropertyException(Messages.TheRelationBetweenTheLedgerAndTheCompanyCannotBeRemovedBecauseAtLeastOneGeneralLedgerTransactionHasBeenPosted, PXErrorLevel.RowError, LinkCache.GetValueExt <OrganizationLedgerLink.ledgerID>(link), org.OrganizationCD.Trim() )); } } return(null); }
public virtual IEnumerable deleteOrganizationLedgerLink(PXAdapter adapter) { var link = LinkCache.Current as OrganizationLedgerLink; if (link?.OrganizationID == null || link.LedgerID == null) { return(adapter.Get()); } Ledger ledger = GeneralLedgerMaint.FindLedgerByID(Base, link.LedgerID); if (ledger.BalanceType == LedgerBalanceType.Actual) { LinkCache.Delete(link); } else { if (GLUtility.RelatedGLHistoryExists(Base, link.LedgerID, link.OrganizationID)) { Organization org = OrganizationMaint.FindOrganizationByID(Base, link.OrganizationID, true); WebDialogResult dialogResult = OrganizationLedgerLinkSelect.Ask(PXMessages.LocalizeFormatNoPrefix( Messages.AtLeastOneGeneralLedgerTransactionHasBeenPosted, LinkCache.GetValueExt <OrganizationLedgerLink.ledgerID>(link).ToString().Trim(), org.OrganizationCD.Trim()), MessageButtons.YesNo); if (dialogResult == WebDialogResult.Yes) { LinkCache.Delete(link); } } else { LinkCache.Delete(link); } } return(adapter.Get()); }