protected virtual void FillPaymentDetails(IPaymentTypeDetailMaster account) { if (account != null) { if (!string.IsNullOrEmpty(account.VPaymentMethodID)) { PaymentMethod paymentTypeDef = PXSelect <PaymentMethod, Where <PaymentMethod.paymentMethodID, Equal <Required <PaymentMethod.paymentMethodID> > > > .Select(this, account.VPaymentMethodID); if (paymentTypeDef != null) { List <PaymentMethodDetail> toAdd = new List <PaymentMethodDetail>(); foreach (PaymentMethodDetail it in this.PaymentTypeDetails.Select(account.VPaymentMethodID)) { VendorPaymentMethodDetail detail = null; foreach (VendorPaymentMethodDetail iPDet in this.PaymentDetails.Select(account.BAccountID, account.LocationID, account.VPaymentMethodID)) { if (iPDet.DetailID == it.DetailID) { detail = iPDet; break; } } if (detail == null) { toAdd.Add(it); } } using (ReadOnlyScope rs = new ReadOnlyScope(this.PaymentDetails.Cache)) { foreach (PaymentMethodDetail it in toAdd) { VendorPaymentMethodDetail detail = new VendorPaymentMethodDetail(); detail.BAccountID = account.BAccountID; detail.LocationID = account.LocationID; detail.PaymentMethodID = account.VPaymentMethodID; detail.DetailID = it.DetailID; detail = this.PaymentDetails.Insert(detail); } if (toAdd.Count > 0) { this.PaymentDetails.View.RequestRefresh(); } } } } } }
protected virtual void FillPaymentDetails(IPaymentTypeDetailMaster account) { if (account != null) { if (!string.IsNullOrEmpty(account.VPaymentMethodID)) { PaymentMethod paymentTypeDef = PXSelect<PaymentMethod, Where<PaymentMethod.paymentMethodID, Equal<Required<PaymentMethod.paymentMethodID>>>>.Select(this, account.VPaymentMethodID); if (paymentTypeDef != null) { List<PaymentMethodDetail> toAdd = new List<PaymentMethodDetail>(); foreach (PaymentMethodDetail it in this.PaymentTypeDetails.Select(account.VPaymentMethodID)) { VendorPaymentMethodDetail detail = null; foreach (VendorPaymentMethodDetail iPDet in this.PaymentDetails.Select(account.BAccountID, account.LocationID, account.VPaymentMethodID)) { if (iPDet.DetailID == it.DetailID) { detail = iPDet; break; } } if (detail == null) { toAdd.Add(it); } } using (ReadOnlyScope rs = new ReadOnlyScope(this.PaymentDetails.Cache)) { foreach (PaymentMethodDetail it in toAdd) { VendorPaymentMethodDetail detail = new VendorPaymentMethodDetail(); detail.BAccountID = account.BAccountID; detail.LocationID = account.LocationID; detail.PaymentMethodID = account.VPaymentMethodID; detail.DetailID = it.DetailID; detail = this.PaymentDetails.Insert(detail); } if (toAdd.Count > 0) { this.PaymentDetails.View.RequestRefresh(); } } } } } }
protected virtual void Location_IsAPPaymentInfoSameAsMain_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { CR.Location record = (CR.Location)e.Row; if (record.IsAPPaymentInfoSameAsMain == false) { LocationAPPaymentInfo mainloc = APPaymentInfoLocation.Select(); record.VCashAccountID = mainloc.VCashAccountID; record.VPaymentMethodID = mainloc.VPaymentMethodID; record.VPaymentLeadTime = mainloc.VPaymentLeadTime; record.VPaymentByType = mainloc.VPaymentByType; record.VSeparateCheck = mainloc.VSeparateCheck; record.IsRemitAddressSameAsMain = mainloc.IsRemitAddressSameAsMain; record.VRemitAddressID = mainloc.VRemitAddressID; record.IsRemitContactSameAsMain = mainloc.IsRemitContactSameAsMain; record.VRemitContactID = mainloc.VRemitContactID; record.VPaymentInfoLocationID = record.LocationID; LocationAPPaymentInfo copyloc = new LocationAPPaymentInfo(); copyloc.BAccountID = record.BAccountID; copyloc.LocationID = record.LocationID; copyloc.VCashAccountID = record.VCashAccountID; copyloc.VPaymentMethodID = record.VPaymentMethodID; copyloc.VPaymentLeadTime = record.VPaymentLeadTime; copyloc.VPaymentByType = record.VPaymentByType; copyloc.VSeparateCheck = record.VSeparateCheck; copyloc.IsRemitAddressSameAsMain = record.IsRemitAddressSameAsMain; copyloc.VDefAddressID = record.VDefAddressID; copyloc.VRemitAddressID = record.VRemitAddressID; copyloc.IsRemitContactSameAsMain = record.IsRemitContactSameAsMain; copyloc.VRemitContactID = record.VRemitContactID; copyloc.VDefContactID = record.VDefContactID; if (copyloc.VDefAddressID != copyloc.VRemitAddressID) { Address copyaddr = FindAddress(copyloc.VRemitAddressID); copyaddr = PXCache <Address> .CreateCopy(copyaddr); copyaddr.AddressID = null; copyaddr = RemitAddress.Insert(copyaddr); copyloc.VRemitAddressID = copyaddr.AddressID; record.VRemitAddressID = copyaddr.AddressID; } if (copyloc.VDefContactID != copyloc.VRemitContactID) { Contact copycont = FindContact(copyloc.VRemitContactID); copycont = PXCache <Contact> .CreateCopy(copycont); copycont.ContactID = null; copycont.NoteID = null; copycont = RemitContact.Insert(copycont); copyloc.VRemitContactID = copycont.ContactID; record.VRemitContactID = copycont.ContactID; } foreach (VendorPaymentMethodDetail maindet in this.PaymentDetails.Select(mainloc.BAccountID, mainloc.LocationID, mainloc.VPaymentMethodID)) { VendorPaymentMethodDetail copydet = PXCache <VendorPaymentMethodDetail> .CreateCopy(maindet); copydet.LocationID = copyloc.LocationID; this.PaymentDetails.Insert(copydet); } BusinessAccount.Cache.Current = (BAccount)PXParentAttribute.SelectParent(sender, e.Row, typeof(BAccount)); APPaymentInfoLocation.Insert(copyloc); } if (record.IsAPPaymentInfoSameAsMain == true) { foreach (VendorPaymentMethodDetail copydet in this.PaymentDetails.Select(record.BAccountID, record.LocationID, record.VPaymentMethodID)) { this.PaymentDetails.Delete(copydet); } BAccount baccount = (BAccount)PXParentAttribute.SelectParent(sender, e.Row, typeof(BAccount)); if (baccount != null) { record.VPaymentInfoLocationID = baccount.DefLocationID; Location mainloc = PXSelect <CR.Location, Where <CR.Location.bAccountID, Equal <Required <CR.Location.bAccountID> >, And <CR.Location.locationID, Equal <Required <CR.Location.locationID> > > > > .Select(sender.Graph, baccount.BAccountID, baccount.DefLocationID); if (mainloc != null) { if (record.DefAddressID != record.VRemitAddressID && mainloc.VRemitAddressID != record.VRemitAddressID) { Address copyaddr = FindAddress(record.VRemitAddressID); RemitAddress.Delete(copyaddr); } if (record.DefContactID != record.VRemitContactID && mainloc.VRemitContactID != record.VRemitContactID) { Contact copycont = FindContact(record.VRemitContactID); RemitContact.Delete(copycont); } } } record.VCashAccountID = null; record.VPaymentMethodID = null; record.VPaymentLeadTime = 0; record.VSeparateCheck = false; record.VRemitAddressID = null; record.VRemitContactID = null; } }