Example #1
0
        /// <summary>
        /// cancela un documento por DocEntry
        /// </summary>
        public bool CancelDocument(string pStrDocEntry)
        {
            try
            {
                SAPbobsCOM.Documents lObjDocument = (SAPbobsCOM.Documents)DIApplication.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseInvoices);
                lObjDocument.GetByKey(Convert.ToInt32(pStrDocEntry));
                var lObjCancelDoc = lObjDocument.CreateCancellationDocument();
                lObjCancelDoc.DocDate = DateTime.Now;

                if (lObjCancelDoc.Add() != 0)
                {
                    UIApplication.ShowMessageBox(DIApplication.Company.GetLastErrorDescription());
                    LogService.WriteError("InvoiceDI (AddVoucherDetail) DocEntry:" + pStrDocEntry + " Mensaje:" + DIApplication.Company.GetLastErrorDescription());
                    return(false);
                }
                else
                {
                    LogService.WriteSuccess("Documento cancelado correctamente: " + pStrDocEntry);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogService.WriteError("InvoiceDI (CancelDocument) " + ex.Message);
                LogService.WriteError(ex);
                return(false);
            }
        }