public virtual void SetActualLedgerIDNullInRelatedCompanies(Ledger ledger, int?[] organizationIDs) { IEnumerable <Organization> organizations = OrganizationMaint.FindOrganizationByIDs(Base, organizationIDs, isReadonly: false); foreach (Organization organization in organizations) { Organization organizationCopy = PXCache <Organization> .CreateCopy(organization); organizationCopy.ActualLedgerID = null; OrganizationViewBase.Update(organizationCopy); } }
public virtual void CheckActualLedgerCanBeAssigned(Ledger ledger, int?[] organizationIDs) { IEnumerable <Organization> organizations = OrganizationMaint.FindOrganizationByIDs(Base, organizationIDs, isReadonly: false); foreach (Organization organization in organizations) { if (organization.ActualLedgerID != null && organization.ActualLedgerID != ledger.LedgerID) { Ledger existingLedger = GeneralLedgerMaint.FindLedgerByID(Base, organization.ActualLedgerID, isReadonly: false); throw new PXSetPropertyException(Messages.LedgerCannotBeAssociatedWithTheCompanyBecauseTheActualLedgerHasBeenAlreadyAssociated, ledger.LedgerCD, organization.OrganizationCD.Trim(), existingLedger.LedgerCD); } } }