Exemple #1
0
        public ResultModel CompleteCancel(UserModel user, int businessInvoiceId)
        {
            ResultModel result = new ResultModel();

            try
            {
                BusinessInvoiceDAL businessInvoiceDAL = new BusinessInvoiceDAL();
                InvoiceDAL invoiceDAL = new InvoiceDAL();
                BusinessInvoiceDetailDAL detailDAL = new BusinessInvoiceDetailDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //获取财务票
                    result = businessInvoiceDAL.Get(user, businessInvoiceId);
                    if (result.ResultStatus != 0)
                        return result;

                    BusinessInvoice businessInvoice = result.ReturnValue as BusinessInvoice;
                    if (businessInvoice == null || businessInvoice.BusinessInvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票验证失败";
                        return result;
                    }

                    //获取发票
                    result = invoiceDAL.Get(user, businessInvoice.InvoiceId);
                    if (result.ResultStatus != 0)
                        return result;
                    Operate.Model.Invoice invoice = result.ReturnValue as Operate.Model.Invoice;
                    if (invoice == null || invoice.InvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票获取失败";
                        return result;
                    }

                    //发票
                    result = invoiceDAL.CompleteCancel(user, invoice);
                    if (result.ResultStatus != 0)
                        return result;

                    //获取明细
                    result = detailDAL.Load(user, businessInvoice.BusinessInvoiceId, StatusEnum.已完成);
                    if (result.ResultStatus != 0)
                        return result;

                    List<BusinessInvoiceDetail> details = result.ReturnValue as List<BusinessInvoiceDetail>;
                    if (details == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票明细获取失败";
                        return result;
                    }

                    foreach (BusinessInvoiceDetail detail in details)
                    {
                        result = detailDAL.CompleteCancel(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Exemple #2
0
        public ResultModel Complete(UserModel user, int businessInvoiceId)
        {
            ResultModel result = new ResultModel();

            try
            {
                BusinessInvoiceDAL businessInvoiceDAL = new BusinessInvoiceDAL();
                InvoiceDAL invoiceDAL = new InvoiceDAL();
                BusinessInvoiceDetailDAL detailDAL = new BusinessInvoiceDetailDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //获取业务票
                    result = businessInvoiceDAL.Get(user, businessInvoiceId);
                    if (result.ResultStatus != 0)
                        return result;

                    BusinessInvoice businessInvoice = result.ReturnValue as BusinessInvoice;
                    if (businessInvoice == null || businessInvoice.BusinessInvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票验证失败";
                        return result;
                    }

                    //获取发票
                    result = invoiceDAL.Get(user, businessInvoice.InvoiceId);
                    if (result.ResultStatus != 0)
                        return result;
                    Operate.Model.Invoice invoice = result.ReturnValue as Operate.Model.Invoice;
                    if (invoice == null || invoice.InvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票获取失败";
                        return result;
                    }

                    //获取明细
                    result = detailDAL.Load(user, businessInvoice.BusinessInvoiceId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<BusinessInvoiceDetail> details = result.ReturnValue as List<BusinessInvoiceDetail>;
                    if (details == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票明细获取失败";
                        return result;
                    }

                    //验证
                    switch (invoice.InvoiceType)
                    {
                        case (int)InvoiceTypeEnum.ProvisionalInvoice:
                            //临票验证
                            //必须所有替临终票为已完成状态

                            break;
                    }

                    //发票完成
                    result = invoiceDAL.Complete(user, invoice);
                    if (result.ResultStatus != 0)
                        return result;

                    foreach (BusinessInvoiceDetail detail in details)
                    {
                        result = detailDAL.Complete(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Exemple #3
0
        public ResultModel Goback(UserModel user, int businessInvoiceId)
        {
            ResultModel result = new ResultModel();

            try
            {
                BusinessInvoiceDAL businessInvoiceDAL = new BusinessInvoiceDAL();
                InvoiceDAL invoiceDAL = new InvoiceDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //获取财务票
                    result = businessInvoiceDAL.Get(user, businessInvoiceId);
                    if (result.ResultStatus != 0)
                        return result;

                    BusinessInvoice businessInvoice = result.ReturnValue as BusinessInvoice;
                    if (businessInvoice == null || businessInvoice.BusinessInvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票验证失败";
                        return result;
                    }

                    //获取发票
                    result = invoiceDAL.Get(user, businessInvoice.InvoiceId);
                    if (result.ResultStatus != 0)
                        return result;
                    Operate.Model.Invoice invoice = result.ReturnValue as Operate.Model.Invoice;
                    if (invoice == null || invoice.InvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "发票获取失败";
                        return result;
                    }

                    //撤返发票
                    result = invoiceDAL.Goback(user, invoice);
                    if (result.ResultStatus != 0)
                        return result;

                    //工作流任务关闭
                    DataSourceDAL sourceDAL = new DataSourceDAL();
                    result = sourceDAL.SynchronousStatus(user, invoice);
                    if (result.ResultStatus != 0)
                        return result;

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }