Пример #1
0
        public ResultModel Complete(UserModel user, int fundsInvoiceId)
        {
            ResultModel result = new ResultModel();

            try
            {
                FinanceInvoiceDAL fundsInvoiceDAL = new FinanceInvoiceDAL();
                InvoiceDAL invoiceDAL = new InvoiceDAL();

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

                    FinanceInvoice fundsInvoice = result.ReturnValue as FinanceInvoice;
                    if (fundsInvoice == null || fundsInvoice.FinanceInvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "财务发票验证失败";
                        return result;
                    }

                    //获取发票
                    result = invoiceDAL.Get(user, fundsInvoice.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.Complete(user, invoice);
                    if (result.ResultStatus != 0)
                        return result;

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

            return result;
        }
Пример #2
0
        public ResultModel Update(UserModel user, Operate.Model.Invoice invoice, FinanceInvoice fundsInvoice,string bids)
        {
            ResultModel result = new ResultModel();

            try
            {
                FinanceInvoiceDAL fundsInvoiceDAL = new FinanceInvoiceDAL();
                InvoiceDAL invoiceDAL = new InvoiceDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {

                    //获取财务发票
                    result = fundsInvoiceDAL.Get(user, fundsInvoice.FinanceInvoiceId);
                    if (result.ResultStatus != 0)
                        return result;

                    FinanceInvoice resultFundsInvoice = result.ReturnValue as FinanceInvoice;
                    if (resultFundsInvoice == null || resultFundsInvoice.FinanceInvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "财务发票获取失败";
                        return result;
                    }

                    //更新财务发票
                    resultFundsInvoice.AssetId = fundsInvoice.AssetId;
                    resultFundsInvoice.IntegerAmount = fundsInvoice.IntegerAmount;
                    resultFundsInvoice.NetAmount = fundsInvoice.NetAmount;
                    resultFundsInvoice.MUId = fundsInvoice.MUId;
                    resultFundsInvoice.VATRatio = fundsInvoice.VATRatio;
                    resultFundsInvoice.VATBala = fundsInvoice.VATBala;

                    result = fundsInvoiceDAL.Update(user, resultFundsInvoice);
                    if (result.ResultStatus != 0)
                        return result;

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

                    resultInvoice.InvoiceDate = invoice.InvoiceDate;
                    resultInvoice.InvoiceName = invoice.InvoiceName;
                    resultInvoice.InvoiceBala = invoice.InvoiceBala;
                    resultInvoice.CurrencyId = invoice.CurrencyId;
                    resultInvoice.OutCorpId = invoice.OutCorpId;

                    Corporation outCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.OutCorpId);
                    if (outCorp == null || outCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "开票公司信息错误";
                        return result;
                    }
                    resultInvoice.OutCorpName = outCorp.CorpName;

                    resultInvoice.InCorpId = invoice.InCorpId;
                    Corporation inCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.InCorpId);
                    if (inCorp == null || inCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "收票公司信息错误";
                        return result;
                    }
                    resultInvoice.InCorpName = inCorp.CorpName;
                    resultInvoice.Memo = invoice.Memo;

                    result = invoiceDAL.Update(user, resultInvoice);
                    if (result.ResultStatus != 0)
                        return result;

                    if (!string.IsNullOrEmpty(bids))
                    {
                        FinBusInvAllotDAL finBusInvAllotDAL = new FinBusInvAllotDAL();
                        FinBusInvAllotDetailDAL finBusInvAllotDetailDAL = new FinBusInvAllotDetailDAL();
                        result = finBusInvAllotDetailDAL.GetAllotIdByFid(user, fundsInvoice.FinanceInvoiceId);
                        if (result.ResultStatus != 0)
                            return result;

                        int allotId = (int)result.ReturnValue;

                        result = finBusInvAllotDAL.Get(user, allotId);
                        if (result.ResultStatus != 0)
                            return result;

                        FinBusInvAllot finBusInvAllot = result.ReturnValue as FinBusInvAllot;
                        finBusInvAllot.AllotBala = invoice.InvoiceBala;

                        result = finBusInvAllotDAL.Update(user, finBusInvAllot);
                        if (result.ResultStatus != 0)
                            return result;

                        result = finBusInvAllotDetailDAL.InvalidAll(user, allotId);
                        if (result.ResultStatus != 0)
                            return result;

                        foreach (string businessInvoiceId in bids.Split(','))
                        {
                            result = invoiceDAL.GetByBussinessInvoiceId(user, Convert.ToInt32(businessInvoiceId));
                            if (result.ResultStatus != 0)
                                return result;

                            Operate.Model.Invoice busInvoice = result.ReturnValue as Operate.Model.Invoice;

                            result = finBusInvAllotDetailDAL.Insert(user, new FinBusInvAllotDetail()
                            {
                                AllotId = allotId,
                                BusinessInvoiceId = Convert.ToInt32(businessInvoiceId),
                                FinanceInvoiceId = fundsInvoice.FinanceInvoiceId,
                                AllotBala = busInvoice.InvoiceBala,
                                DetailStatus = StatusEnum.已生效
                            });
                            if (result.ResultStatus != 0)
                                return result;
                        }

                    }

                    if (result.ResultStatus == 0)
                        result.ReturnValue = invoice.InvoiceId;

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

            return result;
        }
Пример #3
0
        public ResultModel Update(UserModel user, Operate.Model.Invoice invoice, FinanceInvoice fundsInvoice)
        {
            ResultModel result = new ResultModel();

            try
            {
                FinanceInvoiceDAL fundsInvoiceDAL = new FinanceInvoiceDAL();
                InvoiceDAL invoiceDAL = new InvoiceDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {

                    //获取财务发票
                    result = fundsInvoiceDAL.Get(user, fundsInvoice.FinanceInvoiceId);
                    if (result.ResultStatus != 0)
                        return result;

                    FinanceInvoice resultFundsInvoice = result.ReturnValue as FinanceInvoice;
                    if (resultFundsInvoice == null || resultFundsInvoice.FinanceInvoiceId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "财务发票获取失败";
                        return result;
                    }

                    //更新财务发票
                    resultFundsInvoice.AssetId = fundsInvoice.AssetId;
                    resultFundsInvoice.IntegerAmount = fundsInvoice.IntegerAmount;
                    resultFundsInvoice.NetAmount = fundsInvoice.NetAmount;
                    resultFundsInvoice.MUId = fundsInvoice.MUId;
                    resultFundsInvoice.VATRatio = fundsInvoice.VATRatio;
                    resultFundsInvoice.VATBala = fundsInvoice.VATBala;

                    result = fundsInvoiceDAL.Update(user, resultFundsInvoice);
                    if (result.ResultStatus != 0)
                        return result;

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

                    resultInvoice.InvoiceDate = invoice.InvoiceDate;
                    resultInvoice.InvoiceName = invoice.InvoiceName;
                    resultInvoice.InvoiceBala = invoice.InvoiceBala;
                    resultInvoice.CurrencyId = invoice.CurrencyId;
                    resultInvoice.OutCorpId = invoice.OutCorpId;

                    Corporation outCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.OutCorpId);
                    if (outCorp == null || outCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "开票公司信息错误";
                        return result;
                    }
                    resultInvoice.OutCorpName = outCorp.CorpName;

                    resultInvoice.InCorpId = invoice.InCorpId;
                    Corporation inCorp = UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == invoice.InCorpId);
                    if (inCorp == null || inCorp.CorpId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "收票公司信息错误";
                        return result;
                    }
                    resultInvoice.InCorpName = inCorp.CorpName;
                    resultInvoice.Memo = invoice.Memo;

                    result = invoiceDAL.Update(user, resultInvoice);
                    if (result.ResultStatus != 0)
                        return result;

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

            return result;
        }