public virtual IAddressBase GetToAddress(APInvoice invoice, APTran tran, GetToAddressLineDelegate del)
        {
            int?SOID = GetSOIDRelated(tran);

            if (SOID != null)
            {
                IAddressBase returnAddress = null;

                returnAddress = PXSelectJoin <FSAddress,
                                              InnerJoin <
                                                  FSBranchLocation,
                                                  On <FSBranchLocation.branchLocationAddressID, Equal <FSAddress.addressID> >,
                                                  InnerJoin <FSServiceOrder,
                                                             On <FSServiceOrder.branchLocationID, Equal <FSBranchLocation.branchLocationID> > > >,
                                              Where <
                                                  FSServiceOrder.sOID, Equal <Required <FSServiceOrder.sOID> > > >
                                .Select(Base, SOID)
                                .RowCast <FSAddress>()
                                .FirstOrDefault();

                return(returnAddress);
            }

            return(del(invoice, tran));
        }
Exemple #2
0
        protected override void APInvoice_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            APInvoice item = (APInvoice)e.Row;

            if (item.OrigModule == GL.BatchModule.TX)
            {
                base.APInvoice_RowSelected(sender, e);

                addInvoices.SetEnabled(item.VendorID != null && item.VendorLocationID != null && item.Released == false && item.Voided == false);
                prebook.SetEnabled(false);
                prebook.SetVisible(false);
                voidInvoice.SetVisible(false);
                voidInvoice.SetEnabled(false);
            }
            else
            {
                PXUIFieldAttribute.SetEnabled(DocumentList.Cache, e.Row, false);
                PXUIFieldAttribute.SetEnabled <APInvoice.selected>(DocumentList.Cache, e.Row, true);
            }

            Transactions.Cache.AllowInsert = false;
            Transactions.Cache.AllowUpdate = false;
            Transactions.Cache.AllowDelete = false;
        }
Exemple #3
0
        protected virtual void DRSchedule_RefNbr_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            DRSchedule row = e.Row as DRSchedule;

            if (row != null)
            {
                if (row.Module == BatchModule.AR)
                {
                    ARInvoice invoice = PXSelect <ARInvoice, Where <ARInvoice.docType, Equal <Current <DRSchedule.docType> >, And <ARInvoice.refNbr, Equal <Current <DRSchedule.refNbr> > > > > .Select(this);

                    if (invoice != null)
                    {
                        object oldRow = sender.CreateCopy(row);
                        row.BAccountID = invoice.CustomerID;
                        sender.RaiseFieldUpdated <DRSchedule.bAccountID>(row, oldRow);
                    }
                }
                else if (row.Module == BatchModule.AP)
                {
                    APInvoice bill = PXSelect <APInvoice, Where <APInvoice.docType, Equal <Current <DRSchedule.docType> >, And <APInvoice.refNbr, Equal <Current <DRSchedule.refNbr> > > > > .Select(this);

                    if (bill != null)
                    {
                        object oldRow = sender.CreateCopy(row);
                        row.BAccountID = bill.VendorID;
                        sender.RaiseFieldUpdated <DRSchedule.bAccountID>(row, oldRow);
                    }
                }
            }
        }
        public static FinDocumentExtKey GetSourceEntityKeyByRetainage(PXGraph graph, string docType, string refNbr, int?lineNbr)
        {
            FinDocumentExtKey key = new FinDocumentExtKey();

            APInvoice bill = GetInvoice(graph, docType, refNbr);

            if (bill.IsRetainageDocument == true)
            {
                key.Type   = bill.OrigDocType;
                key.RefNbr = bill.OrigRefNbr;

                if (lineNbr != null && lineNbr != 0)
                {
                    key.LineNbr = TransactionDataProvider.GetTransaction(graph, bill.DocType, bill.RefNbr, lineNbr)
                                  .OrigLineNbr;
                }
            }
            else
            {
                key.Type    = docType;
                key.RefNbr  = refNbr;
                key.LineNbr = lineNbr;
            }

            return(key);
        }
        public HttpResponseMessage PostAPInvoice(string recordnumber, string invoicedate, string invoicenumber, string vendornumber, string vendorname, string ponumber, string invoicetypecd)
        {
            try
            {
                if (!String.IsNullOrEmpty(recordnumber))
                {
                    if (db.APInvoices.Count(x => x.Record_Number == recordnumber) > 0)
                    {
                        return(Request.CreateResponse(HttpStatusCode.Conflict));
                    }
                    var apinvoicerecord = new APInvoice {
                        Record_Number = recordnumber, Invoice_Date = Convert.ToDateTime(invoicedate), Invoice_Number = invoicenumber, Vendor_Number = vendornumber, Vendor_Name = vendorname, PO_Number = ponumber, Invoice_Type_cd = invoicetypecd
                    };
                    db.APInvoices.Add(apinvoicerecord);
                    db.SaveChanges();

                    return(Request.CreateResponse <APInvoice>(HttpStatusCode.Created, apinvoicerecord));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest));
                }
            }
            catch (Exception ex)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
Exemple #6
0
        /// <summary>
        /// Rutina para añadir los desgloses de IVA correspondientes por cada factura.
        /// </summary>
        /// <param name="_CamposReg"></param>
        /// <param name="_FacturaActual"></param>
        /// <returns></returns>

        private APInvoice AgregarDesgloseIVA(string[] _CamposReg, APInvoice _FacturaActual)
        {
            // Procedemos a tratar la factura actual.
            // En este caso añadiremos las líneas de fiscalidad que hayamos leido a la factura que estemos tratando en ese momento

            string TipoInversion = _CamposReg[2];

            switch (TipoInversion)
            {
            case "S1":
                _FacturaActual.IsInversionSujetoPasivo = false;
                break;

            case "S2":
                _FacturaActual.IsInversionSujetoPasivo = true;
                break;
            }

            decimal _TipoImpos, _BaseImpos, _CuotaImpos;

            _TipoImpos  = Convert.ToDecimal(_CamposReg[3]);
            _BaseImpos  = Convert.ToDecimal(_CamposReg[4]);
            _CuotaImpos = Convert.ToDecimal(_CamposReg[5]);

            _FacturaActual.AddTaxOtuput(_TipoImpos, _BaseImpos, _CuotaImpos);

            return(_FacturaActual);
        }
Exemple #7
0
        public ActionResult SearchAPInvoice(string documentNo)
        {
            if (documentNo != "0")
            {
                APInvoice apinvoice = null;

                apinvoice = new NetStock.BusinessFactory.APInvoiceBO().GetAPInvoice(new APInvoice {
                    DocumentNo = documentNo
                });

                if (apinvoice == null)
                {
                    apinvoice = new APInvoice();
                    apinvoice.DocumentDate     = DateTime.Today.Date;
                    apinvoice.APInvoiceDetails = new List <APInvoiceDetail>();
                }


                return(RedirectToAction("APInvoice", new { InvoiceType = "", DocumentNo = documentNo }));
                //return View("CBReceipt", cbReceipt);
            }
            else
            {
                return(RedirectToAction("APInvoice"));
            }
        }
        public void Validate(List <APAdjust> adjustments)
        {
            foreach (var adjustment in adjustments)
            {
                var invoice = InvoiceDataProvider.GetInvoice(Graph, adjustment.AdjdDocType, adjustment.AdjdRefNbr);

                var invoiceJCExt = invoice.GetExtension <APInvoiceJCExt>();

                if (invoiceJCExt.IsJointPayees == true)
                {
                    APInvoice origBill = null;

                    if (invoice.IsRetainageDocument == true)
                    {
                        origBill = InvoiceDataProvider.GetOriginalInvoice(Graph, invoice);
                    }

                    if (PaymentCycleWorkflowIsStartedAndItIsOtherPayment(adjustment.AdjgDocType,
                                                                         adjustment.AdjgRefNbr,
                                                                         origBill?.DocType ?? invoice.DocType,
                                                                         origBill?.RefNbr ?? invoice.RefNbr))
                    {
                        ShowErrorMessage <APAdjust.adjdRefNbr>(adjustment,
                                                               JointCheckMessages.PaymentCycleWorkflowIsStarted);
                    }
                }
            }
        }
Exemple #9
0
        protected virtual void APInvoice_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            APInvoice document = e.Row as APInvoice;

            if (document == null)
            {
                return;
            }

            var invoiceState = Base.GetDocumentState(cache, document);

            addPOOrder.SetVisible(invoiceState.IsDocumentInvoice);

            PXUIFieldAttribute.SetEnabled(poorderslist.Cache, null, false);

            bool allowAddPOOrder = invoiceState.IsDocumentEditable &&
                                   invoiceState.AllowAddPOByProject &&
                                   Base.vendor.Current != null &&
                                   !invoiceState.IsRetainageDebAdj;

            addPOOrder.SetEnabled(allowAddPOOrder);
            PXUIFieldAttribute.SetEnabled <POOrderRS.selected>(poorderslist.Cache, null, allowAddPOOrder);
            PXUIFieldAttribute.SetVisible <POOrderRS.unbilledOrderQty>(poorderslist.Cache, null, invoiceState.IsDocumentInvoice);
            PXUIFieldAttribute.SetVisible <POOrderRS.curyUnbilledOrderTotal>(poorderslist.Cache, null, invoiceState.IsDocumentInvoice);
        }
Exemple #10
0
 /// <summary>
 /// Reinicia los parámetros de búsqueda.
 /// </summary>
 private void ResetFactura()
 {
     _FactParaBuscar = new APInvoice
     {
         SellerParty = new Party()
     };
 }
Exemple #11
0
 private Location GetInvoiceLocation(APInvoice invoice)
 {
     return(SelectFrom <Location>
            .Where <Location.bAccountID.IsEqual <P.AsInt>
                    .And <Location.locationID.IsEqual <P.AsInt> > > .View
            .Select(PaymentEntry, invoice.VendorID, invoice.PayLocationID));
 }
        public virtual decimal?GetVendorPreparedBalance(APAdjust adjustment)
        {
            FinDocumentExtKey actualDocLineKey = InvoiceDataProvider.GetSourceEntityKeyByRetainage(Graph,
                                                                                                   adjustment.AdjdDocType, adjustment.AdjdRefNbr, adjustment.AdjdLineNbr);

            decimal?fullAmount;

            if (adjustment.AdjdLineNbr == 0)
            {
                APInvoice bill = InvoiceDataProvider.GetInvoice(Graph, actualDocLineKey.Type, actualDocLineKey.RefNbr);

                fullAmount = bill.CuryOrigDocAmt + bill.CuryRetainageTotal;
            }
            else
            {
                APTran tran = TransactionDataProvider.GetTransaction(Graph, actualDocLineKey.Type, actualDocLineKey.RefNbr, actualDocLineKey.LineNbr);

                fullAmount = tran.CuryOrigTranAmt + tran.CuryRetainageAmt;
            }

            var totalJointAmountOwed = JointPayeeDataProvider.GetJointPayees(Graph, actualDocLineKey.RefNbr, actualDocLineKey.LineNbr)
                                       .Sum(jp => jp.JointAmountOwed.GetValueOrDefault());
            var totalVendorPaymentAmount   = GetTotalVendorPaymentAmount(adjustment, actualDocLineKey.RefNbr, actualDocLineKey.LineNbr);
            var currentVendorPaymentAmount = GetVendorPaymentAmount(adjustment);
            var reversedRetainageAmount    = GetReversedRetainageAmount(actualDocLineKey.RefNbr, actualDocLineKey.LineNbr);

            return(fullAmount + reversedRetainageAmount - totalJointAmountOwed
                   - (totalVendorPaymentAmount - currentVendorPaymentAmount));
        }
Exemple #13
0
        public virtual FSCreatedDoc PressSave(int batchID, BeforeSaveDelegate beforeSave)
        {
            if (Base.Document.Current == null)
            {
                throw new SharedClasses.TransactionScopeException();
            }

            if (beforeSave != null)
            {
                beforeSave(Base);
            }

            Base.Save.Press();

            APInvoice apInvoiceRow = Base.Document.Current;

            var fsCreatedDocRow = new FSCreatedDoc()
            {
                BatchID        = batchID,
                PostTo         = ID.Batch_PostTo.AP,
                CreatedDocType = apInvoiceRow.DocType,
                CreatedRefNbr  = apInvoiceRow.RefNbr
            };

            return(fsCreatedDocRow);
        }
Exemple #14
0
        protected virtual void APInvoice_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            if (e.Row == null || SharedFunctions.isFSSetupSet(Base) == false)
            {
                return;
            }

            APInvoice apInvoiceRow = (APInvoice)e.Row;

            if (e.Operation == PXDBOperation.Update &&
                (Base.Accessinfo.ScreenID != SharedFunctions.SetScreenIDToDotFormat(ID.ScreenID.INVOICE_BY_APPOINTMENT) &&
                 Base.Accessinfo.ScreenID != SharedFunctions.SetScreenIDToDotFormat(ID.ScreenID.INVOICE_BY_SERVICE_ORDER)))
            {
                FSCreatedDoc fsCreatedDocRow = PXSelectJoin <FSCreatedDoc,
                                                             InnerJoin <FSPostBatch, On <FSCreatedDoc.batchID, Equal <FSPostBatch.batchID> > >,
                                                             Where <
                                                                 FSPostBatch.status, Equal <FSPostBatch.status.temporary>,
                                                                 And <FSPostBatch.postTo, Equal <FSPostBatch.postTo.AP>,
                                                                      And <FSCreatedDoc.createdRefNbr, Equal <Required <FSCreatedDoc.createdRefNbr> >,
                                                                           And <FSCreatedDoc.createdDocType, Equal <Required <FSCreatedDoc.createdDocType> > > > > > >
                                               .Select(Base, apInvoiceRow.RefNbr, apInvoiceRow.DocType);

                if (fsCreatedDocRow != null)
                {
                    throw new PXException(TX.Error.CANNOT_UPDATE_DOCUMENT_BECAUSE_BATCH_STATUS_IS_TEMPORARY);
                }
            }
        }
Exemple #15
0
        private void TryFillValuesFromPDF(PXCache invoiceCache, APInvoice invoice, PXCache emailCache, CRSMEmail email)
        {
            string[] content = PDFParser.ParseFirstFileAsPDF(invoiceCache, invoice, emailCache, email);
            if (content != null)
            {
                PXSelectBase <Vendor> select = new PXSelect <Vendor, Where <
                                                                 Vendor.acctCD, Equal <Required <Vendor.acctCD> >,
                                                                 Or <Vendor.acctName, Equal <Required <Vendor.acctName> > > > >(Base);

                int?vendorID = null;

                foreach (string phrase in content)
                {
                    Vendor vendor = select.SelectSingle(phrase.Trim(), phrase.Trim());

                    if (vendor != null)
                    {
                        vendorID = vendor.BAccountID;
                        break;
                    }
                }

                invoice.VendorID = vendorID;
            }
        }
Exemple #16
0
        public virtual IEnumerable createAP(PXAdapter adapter)
        {
            UploadFileRevision file = PXSelectJoin <UploadFileRevision,
                                                    InnerJoin <UploadFile,
                                                               On <UploadFileRevision.fileID, Equal <UploadFile.fileID>,
                                                                   And <UploadFileRevision.fileRevisionID, Equal <UploadFile.lastRevisionID> > >,
                                                               InnerJoin <NoteDoc,
                                                                          On <NoteDoc.fileID, Equal <UploadFile.fileID> > > >,
                                                    Where <NoteDoc.noteID, Equal <Required <CRSMEmail.noteID> >,
                                                           And <UploadFile.name, Like <pdfExtension> > >,
                                                    OrderBy <Desc <UploadFileRevision.createdDateTime> > > .Select(Base, Base.Emails.Current.NoteID);

            string url = null;

            if (file != null)
            {
                string rooturl;

                if (HttpContext.Current == null)
                {
                    rooturl = string.Empty;
                }

                var applicationpath = string.IsNullOrEmpty(HttpContext.Current.Request.ApplicationPath)
                                        ? string.Empty
                                        : HttpContext.Current.Request.ApplicationPath + "/";
                rooturl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + applicationpath;

                url = string.Concat(rooturl != null ? rooturl : string.Empty, HandlerURL, file.FileID.GetValueOrDefault(Guid.Empty).ToString("D"));

                CRSMEmail email = Base.Emails.Current;

                APInvoiceEntryPXInhExt graph = PXGraph.CreateInstance <APInvoiceEntryPXInhExt>();
                graph.Clear();
                APInvoice doc = (APInvoice)graph.Document.Cache.CreateInstance();
                doc.GetExtension <APInvoiceExt>().UsrFileURL = url;
                doc.LineCntr = 0;
                TryFillValuesFromPDF(graph.Document.Cache, doc, Base.Emails.Cache, email);
                doc = graph.Document.Insert(doc);

                (email).Selected = false;
                CRSMEmail copy = PXCache <CRSMEmail> .CreateCopy(email);

                CRActivity newActivity = (CRActivity)graph.Caches[typeof(CRActivity)].Insert();

                copy.BAccountID = newActivity.BAccountID;
                copy.ContactID  = newActivity.ContactID;
                copy.RefNoteID  = newActivity.RefNoteID;
                copy.MPStatus   = MailStatusListAttribute.Processed;
                copy.Exception  = null;
                PXRefNoteSelectorAttribute.EnsureNotePersistence(Base, Base.entityFilter.Current.Type, Base.entityFilter.Current.RefNoteID);
                copy = Base.Emails.Update(copy);
                Base.Save.Press();

                PXNoteAttribute.CopyNoteAndFiles(Base.Emails.Cache, Base.Emails.Current, graph.Document.Cache, doc);
                PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);
            }
            return(adapter.Get());
        }
Exemple #17
0
 /// <summary>
 /// Reinicia la factura en curso.
 /// </summary>
 private void ResetFactura()
 {
     _FacturaParaBuscar = new APInvoice
     {
         BuyerParty  = _Buyer,     // El emisor de la factura
         SellerParty = new Party() // El cliente
     };                            // factura
 }
Exemple #18
0
        private void SetAmountToPay(APInvoice invoice, APAdjust adjustment)
        {
            var adjustmentExtension = PXCache <APAdjust> .GetExtension <ApAdjustExt>(adjustment);

            var invoiceExtension = PXCache <APInvoice> .GetExtension <APInvoiceJCExt>(invoice);

            adjustmentExtension.AmountToPayPerLine = invoiceExtension.AmountToPay;
        }
        protected virtual decimal?GetOpenBalanceByAllBillsFromRetainageGroup(APInvoice invoice)
        {
            var originalBill          = InvoiceDataProvider.GetOriginalInvoice(Graph, invoice.RefNbr, invoice.DocType);
            var relatedRetainageBills =
                InvoiceDataProvider.GetRelatedRetainageBills(Graph, originalBill.RefNbr, originalBill.DocType);

            return(originalBill.CuryDocBal + originalBill.CuryRetainageUnreleasedAmt +
                   relatedRetainageBills.Sum(x => x.CuryDocBal));
        }
Exemple #20
0
        public List <APInvoice> GetAPInvoiceDetails(string invoiceNumber, string vendorName)
        {
            List <APInvoice> list             = new List <APInvoice>();
            OracleConnection oracleConnection = new OracleConnection(_constr);

            try
            {
                System.Data.DataTable dt = new System.Data.DataTable();

                OpenConnection(oracleConnection);
                string _script = "SELECT * FROM XX_AP_INVOICE_DETAIL_V where INVOICE_NUMBER LIKE '" + invoiceNumber + "'";
                if (vendorName != string.Empty)
                {
                    _script = _script + " and VENDOR_NAME LIKE '" + vendorName + "'";
                }
                OracleCommand oracleCommand = new OracleCommand(_script, oracleConnection);

                OracleDataAdapter da = new OracleDataAdapter(_script, oracleConnection);
                da.Fill(dt);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    APInvoice aPInvoice = new APInvoice();
                    aPInvoice.INVOICE_ID               = dt.Rows[i]["INVOICE_ID"].ToString();
                    aPInvoice.INVOICE_NUMBER           = dt.Rows[i]["INVOICE_NUMBER"].ToString();
                    aPInvoice.INVOICE_DESCRIPTION      = dt.Rows[i]["INVOICE_DESCRIPTION"].ToString();
                    aPInvoice.SITE_NAME                = dt.Rows[i]["SITE_NAME"].ToString();
                    aPInvoice.CREATION_DATE            = Convert.ToDateTime(dt.Rows[i]["CREATION_DATE"]);
                    aPInvoice.INVOICE_DATE             = Convert.ToDateTime(dt.Rows[i]["INVOICE_DATE"]);
                    aPInvoice.DUE_DATE                 = Convert.ToDateTime(dt.Rows[i]["DUE_DATE"]);
                    aPInvoice.VENDOR_NAME              = dt.Rows[i]["VENDOR_NAME"].ToString();
                    aPInvoice.INVOICE_AMOUNT           = Convert.ToInt32(dt.Rows[i]["INVOICE_AMOUNT"]);
                    aPInvoice.TOTAL_PAYMENT_AMOUNT     = Convert.ToInt32(dt.Rows[i]["TOTAL_PAYMENT_AMOUNT"]);
                    aPInvoice.INVOICE_TYPE_LOOKUP_CODE = dt.Rows[i]["INVOICE_TYPE_LOOKUP_CODE"].ToString();
                    aPInvoice.INVOICE_APPROVAL_STATUS  = dt.Rows[i]["INVOICE_APPROVAL_STATUS"].ToString();
                    aPInvoice.LAST_UPDATE_DATE         = Convert.ToDateTime(dt.Rows[i]["LAST_UPDATE_DATE"]);
                    aPInvoice.SOURCE         = dt.Rows[i]["SOURCE"].ToString();
                    aPInvoice.VOUCHER_NUM    = dt.Rows[i]["VOUCHER_NUM"].ToString();
                    aPInvoice.ACTION_DATE    = dt.Rows[i]["ACTION_DATE"].ToString() != string.Empty ? Convert.ToDateTime(dt.Rows[i]["ACTION_DATE"]) : new DateTime();
                    aPInvoice.INVOICE_STATUS = dt.Rows[i]["INVOICE_STATUS"].ToString();
                    aPInvoice.PAYMENT_STATUS = dt.Rows[i]["PAYMENT_STATUS"].ToString();
                    aPInvoice.GL_DATE        = Convert.ToDateTime(dt.Rows[i]["GL_DATE"]);
                    list.Add(aPInvoice);
                }

                return(list);
            }
            catch (Exception ex)
            {
                CloseConnection(oracleConnection);
            }
            finally
            {
                CloseConnection(oracleConnection);
            }

            return(list);
        }
Exemple #21
0
        protected override decimal?GetOpenBalanceByAllBillsFromRetainageGroup(APInvoice invoice)
        {
            var originalInvoice                  = InvoiceDataProvider.GetOriginalInvoice(Graph, invoice.RefNbr, invoice.DocType);
            var billLineNumbers                  = JointPayees.Select(jp => jp.BillLineNumber).ToList();
            var unreleasedRetainageAmount        = GetUnreleasedRetainageAmount(originalInvoice, billLineNumbers);
            var releasedAmountFromRetainageGroup = GeReleasedAmountFromRetainageGroup(invoice, billLineNumbers);

            return(invoice.CuryDocBal + unreleasedRetainageAmount + releasedAmountFromRetainageGroup);
        }
Exemple #22
0
        /// <summary>
        /// Busqueda: Actualiza los datos del modelo
        /// con los datos actuales de la vista.
        /// </summary>
        private void BindModelBusqueda()
        {
            _FactParaBuscar = new APInvoice();

            // Chequear datos
            DateTime issueDate;

            if (!DateTime.TryParse(txFechaBusqueda.Text, out issueDate))
            {
                MessageBox.Show("Debe introducir una fecha correcta");
                txFechaBusqueda.Focus();
                return;
            }

            // Necesitamos indicar una fecha de factura, para que se pueda calcular el ejercicio y periodo
            // que son necesarios y obligatorios para realizar esta peticiones.
            _FactParaBuscar.IssueDate = Convert.ToDateTime(issueDate);

            // Si informamos el nombre del Acreedor, el resto de campos son obligatorios y se tienen que informar
            if (!string.IsNullOrEmpty(txNomBusqueda.Text))
            {
                _FactParaBuscar.SellerParty = new Party() // El cliente
                {
                    PartyName = txNomBusqueda.Text
                };

                if (string.IsNullOrEmpty(txNifBusqueda.Text))
                {
                    MessageBox.Show("Si informa el nombre de un Acreedor, también tiene que indicar un NIF");
                    txNifBusqueda.Focus();
                    return;
                }
                else
                {
                    _FactParaBuscar.SellerParty.TaxIdentificationNumber = txNifBusqueda.Text;
                }

                if (lbCountry.Text != "")
                {
                    _FactParaBuscar.CountryCode = lbCountry.Text;
                }

                if (string.IsNullOrEmpty(txFactBusqueda.Text))
                {
                    MessageBox.Show("Si informa el nombre de un Acreedor, también tiene que indicar la serie número de una factura");
                    txFactBusqueda.Focus();
                    return;
                }
                else
                {
                    _FactParaBuscar.InvoiceNumber = txFactBusqueda.Text;
                }
            }


            _PetFactRecEnviadas.APInvoice = _FactParaBuscar;
        }
        public decimal?GetVendorBalancePerBill(APInvoice invoice)
        {
            var openBalanceRelatedRetainageBills = GetOpenBalanceByAllBillsFromRetainageGroup(invoice);
            var jointPayeeBalance = JointPayees.Sum(x => x.JointBalance);
            var availablePaymentAmountForPrimaryVendor = openBalanceRelatedRetainageBills - jointPayeeBalance;

            return(Math.Min(invoice.CuryDocBal.GetValueOrDefault(),
                            availablePaymentAmountForPrimaryVendor.GetValueOrDefault()));
        }
        public APInvoiceWrapper CreateLandedCostBill(POLandedCostDoc doc, IEnumerable <POLandedCostDetail> details, IEnumerable <POLandedCostTaxTran> taxes)
        {
            var apTransactions = CreateTransactions(doc, details);

            var apTaxes = taxes.Select(tax => new APTaxTran()
            {
                Module         = BatchModule.AP,
                TaxID          = tax.TaxID,
                JurisType      = tax.JurisType,
                JurisName      = tax.JurisName,
                TaxRate        = tax.TaxRate,
                CuryID         = doc.CuryID,
                CuryInfoID     = doc.CuryInfoID,
                CuryTaxableAmt = tax.CuryTaxableAmt,
                TaxableAmt     = tax.TaxableAmt,
                CuryTaxAmt     = tax.CuryTaxAmt,
                TaxAmt         = tax.TaxAmt,
                CuryExpenseAmt = tax.CuryExpenseAmt,
                ExpenseAmt     = tax.ExpenseAmt,
                TaxZoneID      = tax.TaxZoneID
            }).ToList();

            var newdoc = new APInvoice();

            newdoc.DocType = APDocType.Invoice;

            if (doc.PayToVendorID.HasValue && doc.PayToVendorID != doc.VendorID && PXAccess.FeatureInstalled <FeaturesSet.vendorRelations>())
            {
                newdoc.VendorID                   = doc.PayToVendorID;
                newdoc.SuppliedByVendorID         = doc.VendorID;
                newdoc.SuppliedByVendorLocationID = doc.VendorLocationID;
            }
            else
            {
                newdoc.VendorID         = doc.VendorID;
                newdoc.VendorLocationID = doc.VendorLocationID;
            }

            newdoc.DocDate     = doc.BillDate;
            newdoc.TaxCalcMode = TaxCalculationMode.TaxSetting;
            newdoc.TermsID     = doc.TermsID;
            newdoc.InvoiceNbr  = doc.VendorRefNbr;
            newdoc.CuryID      = doc.CuryID;
            newdoc.CuryInfoID  = doc.CuryInfoID;
            newdoc.BranchID    = doc.BranchID;
            newdoc.TaxCalcMode = TaxCalculationMode.TaxSetting;

            newdoc.TaxZoneID      = doc.TaxZoneID;
            newdoc.CuryOrigDocAmt = doc.CuryDocTotal;
            newdoc.DueDate        = doc.DueDate;
            newdoc.DiscDate       = doc.DiscDate;
            newdoc.Hold           = false;

            var result = new APInvoiceWrapper(newdoc, apTransactions, apTaxes);

            return(result);
        }
Exemple #25
0
        private void MnViewXML_Click(object sender, EventArgs e)
        {
            // Generaremos el lote para poder dar de baja las facturas que se hayan seleccionado en el DataGrid.
            _LoteBajaFactRecibidas = new Batch(BatchActionKeys.DR, BatchActionPrefixes.BajaLR, BatchTypes.FacturasRecibidas);

            foreach (DataGridViewRow row in grdInvoices.SelectedRows)
            {
                _LoteBajaFactRecibidas.Titular = _Titular;

                APInvoice _FactRecibidaBaja           = new APInvoice();
                RegistroRCLRFacturasRecibidas _regWrk = new RegistroRCLRFacturasRecibidas();

                _regWrk = (RegistroRCLRFacturasRecibidas)row.Cells[5].Value;

                // Sólo daremos de baja aquellas facturas cuyo estado sean correctas, ya que tras realizar varias pruebas,
                // las anuladas también las devuelve y al seleccionarlas se puede producir un error.
                if (_regWrk.EstadoFactura.EstadoRegistro == "Correcta")
                {
                    _FactRecibidaBaja.SellerParty = new Party
                    {
                        PartyName = _regWrk.FacturaRecibida.Contraparte.NombreRazon,
                        TaxIdentificationNumber = _regWrk.FacturaRecibida.Contraparte.NIF
                    };

                    if (_regWrk.FacturaRecibida.Contraparte.IDOtro != null)
                    {
                        _FactRecibidaBaja.CountryCode = _regWrk.FacturaRecibida.Contraparte.IDOtro.CodigoPais;
                    }

                    _FactRecibidaBaja.IssueDate     = Convert.ToDateTime(_regWrk.IDFactura.FechaExpedicionFacturaEmisor);
                    _FactRecibidaBaja.InvoiceNumber = _regWrk.IDFactura.NumSerieFacturaEmisor;

                    _LoteBajaFactRecibidas.BatchItems.Add(_FactRecibidaBaja);
                }
            }

            try
            {
                string tmpath = Path.GetTempFileName();

                // Genera el archivo xml y lo guarda en la ruta facilitada comno parámetro
                _LoteBajaFactRecibidas.GetXml(tmpath);

                FormXmlViewer frmXmlViewer = new FormXmlViewer
                {
                    Path = tmpath
                };

                frmXmlViewer.ShowDialog();
            }
            catch (Exception ex)
            {
                string _msgError = "Error: " + ex.Message;
                MessageBox.Show(_msgError, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public static bool DoesAnyNonReleasedJointPayeePaymentExist(PXGraph graph, APInvoice invoice)
        {
            var query = CreateGetNonReleasedJointPayeePaymentsQuery(graph);

            query.WhereAnd <Where <JointPayeePayment.invoiceRefNbr, Equal <Required <APInvoice.refNbr> >,
                                   And <JointPayeePayment.invoiceDocType, Equal <Required <APInvoice.docType> > > > >();
            var nonReleasedPayments = query.Select(invoice.RefNbr, invoice.DocType).FirstTableItems.ToList();

            return(RefreshJointPayeePayments(graph, nonReleasedPayments).Any());
        }
Exemple #27
0
        /// <summary>
        /// Reinicia la factura en curso.
        /// </summary>
        private void ResetFactura()
        {
            _FacturaEnCurso = new APInvoice
            {
                BuyerParty  = _Buyer,     // El emisor de la factura
                SellerParty = new Party() // El cliente
            };                            // factura

            ChangeCurrentInvoiceIndex(-1);
        }
Exemple #28
0
        private decimal?GeReleasedAmountFromRetainageGroup(APInvoice invoice, IEnumerable <int?> billLineNumbers)
        {
            var allReleasedBillsFromRetainageGroup = InvoiceDataProvider
                                                     .GetAllBillsFromRetainageGroup(Graph, invoice.RefNbr, invoice.DocType)
                                                     .Except(invoice).Where(bill => bill.Released == true);

            return(allReleasedBillsFromRetainageGroup.SelectMany(bill => TransactionDataProvider
                                                                 .GetTransactions(Graph, bill.DocType, bill.RefNbr, billLineNumbers))
                   .Sum(transaction => transaction.CuryTranBal));
        }
Exemple #29
0
        protected virtual void _(Events.RowPersisting <APInvoice> e)
        {
            if (e.Row == null || SharedFunctions.isFSSetupSet(Base) == false)
            {
                return;
            }

            APInvoice apInvoiceRow = (APInvoice)e.Row;

            ValidatePostBatchStatus(e.Operation, ID.Batch_PostTo.AP, apInvoiceRow.DocType, apInvoiceRow.RefNbr);
        }
Exemple #30
0
        public virtual bool IsFSIntegrationEnabled()
        {
            APInvoice apInvoiceRow = Base.Document.Current;

            if (apInvoiceRow.CreatedByScreenID.Substring(0, 2) == "FS")
            {
                return(true);
            }

            return(false);
        }