Example #1
0
        public new virtual IEnumerable ValidateAddresses(PXAdapter adapter)
        {
            BAccount bacct = this.BAccount.Current;

            if (bacct != null)
            {
                bool needSave = false;
                Save.Press();
                Address address = this.DefAddress.Current;
                if (address != null && address.IsValidated == false)
                {
                    PXAddressValidator.Validate <Address>(this, address, true);
                    needSave = true;
                }
                LocationExtAddress locAddress = this.DefLocation.Current;
                if (locAddress != null && locAddress.IsValidated == false && locAddress.AddressID != address.AddressID)
                {
                    PXAddressValidator.Validate <LocationExtAddress>(this, locAddress, true);
                    needSave = true;
                }
                if (needSave == true)
                {
                    this.Save.Press();
                }
            }
            return(adapter.Get());
        }
        public virtual IEnumerable ConverToVendor(PXAdapter adapter)
        {
            BAccount bacct = this.BAccount.Current;

            if (bacct != null && (bacct.Type == BAccountType.ProspectType || bacct.Type == BAccountType.CustomerType))
            {
                Save.Press();
                AP.VendorMaint editingBO = PXGraph.CreateInstance <AP.VendorMaint>();
                AP.VendorR     vendor    = (AP.VendorR)editingBO.BAccount.Cache.Extend <BAccount>(bacct);
                editingBO.BAccount.Current = vendor;
                vendor.Type = (bacct.Type == BAccountType.ProspectType) ? BAccountType.VendorType : BAccountType.CombinedType;
                LocationExtAddress defLocation = editingBO.DefLocation.Select();
                editingBO.DefLocation.Cache.RaiseRowSelected(defLocation);
                string locationType = (bacct.Type == BAccountType.ProspectType) ? LocTypeList.VendorLoc : LocTypeList.CombinedLoc;
                editingBO.InitVendorLocation(defLocation, locationType);
                defLocation = editingBO.DefLocation.Update(defLocation);
                foreach (Location iLoc in editingBO.IntLocations.Select())
                {
                    if (iLoc.LocationID != defLocation.LocationID)
                    {
                        editingBO.InitVendorLocation(iLoc, locationType);
                        editingBO.IntLocations.Update(iLoc);
                    }
                }
                throw new PXRedirectRequiredException(editingBO, Messages.EditVendor);
            }
            return(adapter.Get());
        }
        protected virtual void LocationExtAddress_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)
        {
            if (InvokeBaseHandler != null)
            {
                InvokeBaseHandler(sender, e);
            }

            LocationExtAddress address = e.Row as LocationExtAddress;

            if (address == null)
            {
                return;
            }

            if (address.IsAddressSameAsMain != null)
            {
                bool enabled = !(address.IsAddressSameAsMain ?? false);

                PXUIFieldAttribute.SetEnabled <MXAddressExtension.street>(sender, address, enabled);
                PXUIFieldAttribute.SetEnabled <MXAddressExtension.extNumber>(sender, address, enabled);
                PXUIFieldAttribute.SetEnabled <MXAddressExtension.intNumber>(sender, address, enabled);
                PXUIFieldAttribute.SetEnabled <MXAddressExtension.neighborhood>(sender, address, enabled);
                PXUIFieldAttribute.SetEnabled <MXAddressExtension.municipality>(sender, address, enabled);
                PXUIFieldAttribute.SetEnabled <MXAddressExtension.reference>(sender, address, enabled);
            }
        }
Example #4
0
 public new IEnumerable ViewLocation(PXAdapter adapter)
 {
     if (this.Locations.Current != null && this.BAccountAccessor.Cache.GetStatus(this.BAccountAccessor.Current) != PXEntryStatus.Inserted)
     {
         LocationExtAddress   current = this.Locations.Current;
         CompanyLocationMaint graph   = PXGraph.CreateInstance <CompanyLocationMaint>();
         graph.Location.Current = graph.Location.Search <Location.locationID>(current.LocationID, this.BAccountAccessor.Current.AcctCD);
         throw new PXRedirectRequiredException(graph, CR.Messages.LocationMaint);
     }
     return(adapter.Get());
 }
Example #5
0
        public PayerRecordA CreatePayerARecord(OrganizationBAccount orgBAccount,
                                               Organization organization,
                                               Contact rowMainContact,
                                               Address rowMainAddress,
                                               LocationExtAddress rowShipInfo,
                                               Contact rowShipContact,
                                               MISC1099EFileFilter filter)
        {
            string companyName1 = rowMainContact.FullName.Trim();
            string companyName2 = string.Empty;

            if (companyName1.Length > 40)
            {
                companyName2 = companyName1.Substring(40);
                companyName1 = companyName1.Substring(0, 40);
            }
            return(new PayerRecordA
            {
                RecordType = "A",
                PaymentYear = filter.FinYear,
                CombinedFederalORStateFiler = organization.CFSFiler == true ? "1" : string.Empty,
                Blank1 = string.Empty,
                PayerTaxpayerIdentificationNumberTIN = orgBAccount.TaxRegistrationID,

                PayerNameControl = organization.NameControl,

                LastFilingIndicator = filter.IsLastFiling == true ? "1" : string.Empty,

                TypeofReturn = "A",
                AmountCodes = (filter.ReportingDirectSalesOnly == true) ? "1" : "12345678ABCDE",

                Blank2 = string.Empty,
                ForeignEntityIndicator = organization.ForeignEntity == true ? "1" : string.Empty,
                FirstPayerNameLine = companyName1,
                SecondPayerNameLine = companyName2,

                #region Check with Gabriel, we need Transfer Agent or no
                TransferAgentIndicator = "0",
                #endregion

                PayerShippingAddress = string.Concat(rowShipInfo.AddressLine1, rowShipInfo.AddressLine2),
                PayerCity = rowShipInfo.City,
                PayerState = rowShipInfo.State,
                PayerZipCode = rowShipInfo.PostalCode,

                PayerTelephoneAndExt = rowShipContact.Phone1,

                Blank3 = string.Empty,
                RecordSequenceNumber = (++RecordCounter).ToString(),
                Blank4 = string.Empty,
                Blank5 = string.Empty
            });
        }
Example #6
0
        public PayeeRecordB CreatePayeeBRecord(BranchMaint graph, BranchMaint.BranchBAccount branchRow, MISC1099EFileProcessingInfo Record1099, MISC1099EFileFilter filter)
        {
            PayeeRecordB bRecord;

            graph.Caches <AP1099History>().ClearQueryCache();
            using (new PXReadBranchRestrictedScope(Record1099.PayerBranchID))
            {
                VendorR rowVendor = PXSelect <VendorR, Where <VendorR.bAccountID, Equal <Required <VendorR.bAccountID> > > > .Select(graph, Record1099.VendorID);

                Contact rowVendorContact = PXSelect <Contact,
                                                     Where <Contact.bAccountID, Equal <Required <BAccount.bAccountID> >,
                                                            And <Contact.contactID, Equal <Required <BAccount.defContactID> > > > > .Select(graph, rowVendor.BAccountID, rowVendor.DefContactID);

                Address rowVendorAddress = PXSelect <Address,
                                                     Where <Address.bAccountID, Equal <Required <BAccount.bAccountID> >,
                                                            And <Address.addressID, Equal <Required <BAccount.defAddressID> > > > > .Select(graph, rowVendor.BAccountID, rowVendor.DefAddressID);

                LocationExtAddress rowVendorShipInfo = PXSelect <LocationExtAddress,
                                                                 Where <LocationExtAddress.locationBAccountID, Equal <Required <BAccount.bAccountID> >,
                                                                        And <LocationExtAddress.locationID, Equal <Required <BAccount.defLocationID> > > > > .Select(graph, rowVendor.BAccountID, rowVendor.DefLocationID);

                List <AP1099History> amtList1099 = PXSelectJoinGroupBy <AP1099History,
                                                                        InnerJoin <AP1099Box, On <AP1099History.boxNbr, Equal <AP1099Box.boxNbr> > >,
                                                                        Where <AP1099History.vendorID, Equal <Required <AP1099History.vendorID> >,
                                                                               And <AP1099History.finYear, Equal <Required <AP1099History.finYear> > > >,
                                                                        Aggregate <
                                                                            GroupBy <AP1099History.boxNbr,
                                                                                     Sum <AP1099History.histAmt> > > >
                                                   .Select(graph, Record1099.VendorID, filter.FinYear)
                                                   .Where(res => res.GetItem <AP1099History>().HistAmt >= res.GetItem <AP1099Box>().MinReportAmt)
                                                   .RowCast <AP1099History>()
                                                   .ToList();

                if ((amtList1099.Sum(hist => hist.HistAmt) ?? 0m) == 0m)
                {
                    return(null);
                }

                bRecord = new PayeeRecordB
                {
                    RecordType  = "B",
                    PaymentYear = filter.FinYear,

                    //ALWAYS G since we have one Payee record per file.
                    CorrectedReturnIndicator = filter.IsCorrectionReturn == true ? "G" : string.Empty,

                    NameControl = string.Empty,

                    #region confirmed with Gabriel - ALWAYS Business
                    TypeOfTIN = "1",
                    #endregion

                    PayerTaxpayerIdentificationNumberTIN = rowVendorShipInfo.TaxRegistrationID,

                    PayerAccountNumberForPayee = rowVendor.AcctCD,

                    #region Check with Gabriel, not sure about this
                    PayerOfficeCode = string.Empty,
                    #endregion

                    Blank1 = string.Empty,

                    PaymentAmount1 = filter.ReportingDirectSalesOnly == true ? 0m : Math.Round((amtList1099.FirstOrDefault(v => (v != null && v.BoxNbr == 1)) ?? new AP1099Hist {
                        HistAmt = 0m
                    }).HistAmt ?? 0m, 2),
                    PaymentAmount2 = filter.ReportingDirectSalesOnly == true ? 0m : Math.Round((amtList1099.FirstOrDefault(v => (v != null && v.BoxNbr == 2)) ?? new AP1099Hist {
                        HistAmt = 0m
                    }).HistAmt ?? 0m, 2),
                    PaymentAmount3 = filter.ReportingDirectSalesOnly == true ? 0m : Math.Round((amtList1099.FirstOrDefault(v => (v != null && v.BoxNbr == 3)) ?? new AP1099Hist {
                        HistAmt = 0m
                    }).HistAmt ?? 0m, 2),
                    PaymentAmount4 = filter.ReportingDirectSalesOnly == true ? 0m : Math.Round((amtList1099.FirstOrDefault(v => (v != null && v.BoxNbr == 4)) ?? new AP1099Hist {
                        HistAmt = 0m
                    }).HistAmt ?? 0m, 2),
                    PaymentAmount5 = filter.ReportingDirectSalesOnly == true ? 0m : Math.Round((amtList1099.FirstOrDefault(v => (v != null && v.BoxNbr == 5)) ?? new AP1099Hist {
                        HistAmt = 0m
                    }).HistAmt ?? 0m, 2),
                    PaymentAmount6 = filter.ReportingDirectSalesOnly == true ? 0m : Math.Round((amtList1099.FirstOrDefault(v => (v != null && v.BoxNbr == 6)) ?? new AP1099Hist {
                        HistAmt = 0m
                    }).HistAmt ?? 0m, 2),
                    PaymentAmount7 = filter.ReportingDirectSalesOnly == true ? 0m : Math.Round((amtList1099.FirstOrDefault(v => (v != null && v.BoxNbr == 7)) ?? new AP1099Hist {
                        HistAmt = 0m
                    }).HistAmt ?? 0m, 2),
                    PaymentAmount8 = filter.ReportingDirectSalesOnly == true ? 0m : Math.Round((amtList1099.FirstOrDefault(v => (v != null && v.BoxNbr == 8)) ?? new AP1099Hist {
                        HistAmt = 0m
                    }).HistAmt ?? 0m, 2),
                    //
                    //Need Box 11???
                    PaymentAmount9 = filter.ReportingDirectSalesOnly == true ? 0m : Math.Round((amtList1099.FirstOrDefault(v => (v != null && v.BoxNbr == 9)) ?? new AP1099Hist {
                        HistAmt = 0m
                    }).HistAmt ?? 0m, 2),
                    //
                    PaymentAmountA = filter.ReportingDirectSalesOnly == true ? 0m : Math.Round((amtList1099.FirstOrDefault(v => (v != null && v.BoxNbr == 10)) ?? new AP1099Hist {
                        HistAmt = 0m
                    }).HistAmt ?? 0m, 2),
                    PaymentAmountB = filter.ReportingDirectSalesOnly == true ? 0m : Math.Round((amtList1099.FirstOrDefault(v => (v != null && v.BoxNbr == 13)) ?? new AP1099Hist {
                        HistAmt = 0m
                    }).HistAmt ?? 0m, 2),
                    PaymentAmountC = filter.ReportingDirectSalesOnly == true ? 0m : Math.Round((amtList1099.FirstOrDefault(v => (v != null && v.BoxNbr == 14)) ?? new AP1099Hist {
                        HistAmt = 0m
                    }).HistAmt ?? 0m, 2),
                    Payment        = filter.ReportingDirectSalesOnly == true ? 0m : Math.Round((amtList1099.FirstOrDefault(v => (v != null && v.BoxNbr == 151)) ?? new AP1099Hist {
                        HistAmt = 0m
                    }).HistAmt ?? 0m, 2),
                    PaymentAmountE = filter.ReportingDirectSalesOnly == true ? 0m : Math.Round((amtList1099.FirstOrDefault(v => (v != null && v.BoxNbr == 152)) ?? new AP1099Hist {
                        HistAmt = 0m
                    }).HistAmt ?? 0m, 2),
                    PaymentAmountF = 0m,
                    PaymentAmountG = 0m,

                    ForeignCountryIndicator = rowVendor.ForeignEntity == true ? "1" : string.Empty,
                    PayeeNameLine           = rowVendorContact.FullName,

                    Blank2 = string.Empty,

                    PayeeMailingAddress = string.Concat(rowVendorAddress.AddressLine1, rowVendorAddress.AddressLine2),

                    Blank3 = string.Empty,

                    PayeeCity    = rowVendorAddress.City,
                    PayeeState   = rowVendorAddress.State,
                    PayeeZipCode = rowVendorAddress.PostalCode,

                    Blank4 = string.Empty,

                    RecordSequenceNumber = (++RecordCounter).ToString(),

                    Blank5 = string.Empty,

                    #region Confirmed with Gabriel, Skip for now
                    SecondTINNotice = string.Empty,
                    #endregion

                    Blank6 = string.Empty,

                    #region Check - Dependent on Box 9 - check in 3rd party
                    DirectSalesIndicator = GetDirectSaleIndicator(graph, Record1099.VendorID.Value, filter.FinYear),
                    #endregion

                    FATCA = rowVendor.FATCA == true ? "1": string.Empty,

                    Blank7 = string.Empty,

                    #region Confirmed with Gabriel, skip for now
                    SpecialDataEntries     = string.Empty,
                    StateIncomeTaxWithheld = string.Empty,
                    LocalIncomeTaxWithheld = string.Empty,
                    #endregion

                    CombineFederalOrStateCode = branchRow.CFSFiler == true?GetCombinedFederalOrStateCode(rowVendorAddress.State) : string.Empty,

                                                    Blank8 = string.Empty,
                };
            }
            return(bRecord);
        }