public ResultInfo Update(Guid personnelId, string realName, InvoiceApplyInfo invoiceApplyInfo, List <InvoiceApplyDetailInfo> details)
 {
     try
     {
         var applyInfo = _invoiceApply.GetInvoiceApplyInfo(invoiceApplyInfo.ApplyId);
         if (applyInfo == null)
         {
             return(new ResultInfo(false, "发票申请不存在!"));
         }
         if (applyInfo.ApplyState != (int)ApplyInvoiceState.WaitAudit)
         {
             return(new ResultInfo(false, string.Format("当前发票申请状态为{0}!", Enum.Attribute.EnumAttribute.GetKeyName((ApplyInvoiceState)applyInfo.ApplyState))));
         }
         invoiceApplyInfo.ApplyState = (int)ApplyInvoiceState.WaitAudit;
         if (applyInfo.ApplySourceType == (int)ApplyInvoiceSourceType.League)
         {
             invoiceApplyInfo.Amount = details.Sum(ent => ent.TotalPayAmount);
         }
         var result = _invoiceApply.Modify(invoiceApplyInfo, details);
         if (result)
         {
             string remark = string.Format("[发票申请编辑:{0} {1}]", realName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
             _operationLogManager.Add(personnelId, realName, applyInfo.ApplyId, applyInfo.TradeCode, OperationPoint.CurrentReceivedPayment.Remarks.GetBusinessInfo(), 1, remark);
             return(new ResultInfo(true, string.Empty));
         }
         return(new ResultInfo(false, "发票申请编辑失败!"));
     }
     catch (Exception ex)
     {
         return(new ResultInfo(false, ex.Message));
     }
 }
Exemple #2
0
 private void BindValue(InvoiceApplyInfo applyInfo)
 {
     TbAddress.Text           = applyInfo.Address;
     TbTelephone.Text         = applyInfo.Telephone;
     TbReceiver.Text          = applyInfo.Receiver;
     TbApplyRemark.Text       = applyInfo.ApplyRemark;
     TbRetreat.Text           = applyInfo.RetreatRemark;
     TbTitleType.Text         = EnumAttribute.GetKeyName((ApplyInvoiceTitleType)applyInfo.InvoiceTitleType);
     TbTitle.Text             = applyInfo.Title;
     TbAmount.Text            = applyInfo.Amount.ToString("#0.00");
     TbPerAmount.Text         = applyInfo.Amount.ToString("#0.00");
     TbOrderNo.Text           = applyInfo.TradeCode;
     TbThirdPartyOrderNo.Text = applyInfo.ThirdPartyCode;
     BtSave.Text = IsAudit ? "核准" : "开票";
     BtBack.Text = IsAudit ? "核退" : "退回";
     IsSpecial   = applyInfo.ApplyType == (int)ApplyInvoiceType.Special;
     if (applyInfo.InvoiceTitleType == (int)ApplyInvoiceTitleType.Company)
     {
         TbContactAddress.Text = applyInfo.ContactAddress;
         TbContactPhone.Text   = applyInfo.ContactTelephone;
         TbTaxNumber.Text      = applyInfo.TaxpayerNumber;
         TbBankName.Text       = applyInfo.BankName;
         TbBankAccountNo.Text  = applyInfo.BankAccountNo;
         IsCompany             = true;
     }
     else
     {
         IsCompany = false;
     }
     RAM.ResponseScripts.Add(string.Format("load({0},{1});", !IsCompany?1:0, IsAudit ? 0 : 1));
 }
        /// <summary>
        /// 核退重新编辑发票申请
        /// </summary>
        /// <param name="personnelId">操作人Id(操作日志需要)</param>
        /// <param name="realName">操作人(操作日志需要)</param>
        /// <param name="invoiceApply">发票申请Id</param>
        /// <param name="invoiceApplyDetailInfos">加盟店单据明细(ps:订单类型的发票申请传null)</param>
        /// <returns></returns>
        public ResultInfo AgainApply(Guid personnelId, string realName, InvoiceApplyInfo invoiceApply,
                                     List <InvoiceApplyDetailInfo> invoiceApplyDetailInfos)
        {
            var result = _invoiceApplySerivce.Again(personnelId, realName, invoiceApply, invoiceApplyDetailInfos);

            return(result.IsSuccess ? ResultInfo.Success() : ResultInfo.Failure(result.Message));
        }
Exemple #4
0
 private void BindValue(InvoiceApplyInfo applyInfo)
 {
     TbAddress.Text     = applyInfo.Address;
     TbTelephone.Text   = applyInfo.Telephone;
     TbReceiver.Text    = applyInfo.Receiver;
     TbApplyRemark.Text = applyInfo.ApplyRemark;
     TbRetreat.Text     = applyInfo.RetreatRemark;
     TbLeagueName.Text  = FilialeManager.GetName(applyInfo.TargetId);
     TbInvoiceType.Text = EnumAttribute.GetKeyName((ApplyInvoiceType)applyInfo.ApplyType);
     TbTitleType.Text   = EnumAttribute.GetKeyName((ApplyInvoiceTitleType)applyInfo.InvoiceTitleType);
     TbTitle.Text       = applyInfo.Title;
     TbPerTitle.Text    = applyInfo.Title;
     BtSave.Text        = IsAudit ? "核准" : "开票";
     BtBack.Text        = IsAudit ? "核退" : "退回";
     if (applyInfo.InvoiceTitleType == (int)ApplyInvoiceTitleType.Company)
     {
         TbContactAddress.Text = applyInfo.ContactAddress;
         TbContactPhone.Text   = applyInfo.ContactTelephone;
         TbTaxNumber.Text      = applyInfo.TaxpayerNumber;
         TbBankName.Text       = applyInfo.BankName;
         TbBankAccountNo.Text  = applyInfo.BankAccountNo;
     }
 }
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="realName"></param>
 /// <param name="invoiceApplyInfo"></param>
 /// <param name="details"></param>
 /// <param name="personnelid"></param>
 /// <returns></returns>
 public ResultInfo Insert(Guid personnelid, string realName, InvoiceApplyInfo invoiceApplyInfo, List <InvoiceApplyDetailInfo> details)
 {
     try
     {
         if (invoiceApplyInfo.ApplySourceType == (int)ApplyInvoiceSourceType.League)
         {
             invoiceApplyInfo.Amount = details.Sum(ent => ent.TotalPayAmount);
             if (invoiceApplyInfo.ApplyKind == (int)ApplyInvoiceKindType.Credit)
             {
                 var bindGoods = _storageRecord.GetStorageRecordDetailsByLinkTradeCode(details.Select(ent => ent.Tradecode));
                 foreach (var item in details)
                 {
                     var dataSource = bindGoods.Where(ent => ent.LinkTradeCode == item.Tradecode);
                     if (dataSource.Sum(ent => ent.Quantity * ent.UnitPrice) != item.TotalPayAmount)
                     {
                         return(new ResultInfo(false, string.Format("发票申请插入失败!要货申请{0}和出库总金额不一致", item.Tradecode)));
                     }
                     item.LinkTradeCodes = string.Join(",", dataSource.Select(ent => ent.TradeCode));
                 }
             }
         }
         var result = _invoiceApply.Insert(invoiceApplyInfo, details);
         if (result)
         {
             string remark = string.Format("[发票申请新增:{0} {1}]{2}", realName, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), invoiceApplyInfo.ApplyRemark);
             _operationLogManager.Add(personnelid, realName, invoiceApplyInfo.ApplyId,
                                      invoiceApplyInfo.TradeCode, OperationPoint.CurrentReceivedPayment.Remarks.GetBusinessInfo(), 1,
                                      remark);
             return(new ResultInfo(true, string.Empty));
         }
         return(new ResultInfo(false, "发票申请插入失败!"));
     }
     catch (Exception ex)
     {
         return(new ResultInfo(false, ex.Message));
     }
 }
Exemple #6
0
        public bool Modify(InvoiceApplyInfo invoiceApplyInfo, List <InvoiceApplyDetailInfo> detailInfos)
        {
            const string SQL = @"UPDATE InvoiceApply SET ApplyState=@ApplyState,ApplyType=@ApplyType,ApplyKind,Amount,InvoiceTitleType,Title=@Title,TaxpayerNumber=@TaxpayerNumber,BankName=@BankName,
	BankAccountNo=@BankAccountNo,ContactAddress=@ContactAddress,ContactTelephone=@ContactTelephone,Receiver=@Receiver,Telephone=@Telephone,[Address]=@Address,ApplyRemark=@ApplyRemark,RetreatRemark,SaleFilialeId=@SaleFilialeId,SalePlatformId=@SalePlatformId WHERE ApplyId=@ApplyId"    ;

            const string SQL_DETAIL = @"INSERT INTO InvoiceApplyDetail(Id,ApplyId,Tradecode,LinkTradeCodes,PayBalanceAmount,PayRebateAmount,TotalPayAmount) VALUES(@Id,@ApplyId,@Tradecode,@LinkTradeCodes,@PayBalanceAmount,@PayRebateAmount,@TotalPayAmount)";

            const string SQL_DELETE = @"DELETE InvoiceApplyDetail WHERE ApplyId=@ApplyId";

            try
            {
                using (var db = DatabaseFactory.Create())
                {
                    db.BeginTransaction();
                    db.Execute(false, SQL, new[] {
                        new Parameter("@ApplyId", invoiceApplyInfo.ApplyId),
                        new Parameter("@TargetId", invoiceApplyInfo.TargetId),
                        new Parameter("@ApplyState", invoiceApplyInfo.ApplyState),
                        new Parameter("@ApplyType", invoiceApplyInfo.ApplyType),
                        new Parameter("@ApplyKind", invoiceApplyInfo.ApplyKind),
                        new Parameter("@Amount", invoiceApplyInfo.Amount),
                        new Parameter("@InvoiceTitleType", invoiceApplyInfo.InvoiceTitleType),
                        new Parameter("@Title", invoiceApplyInfo.Title),
                        new Parameter("@TaxpayerNumber", invoiceApplyInfo.TaxpayerNumber),
                        new Parameter("@BankName", invoiceApplyInfo.BankName),
                        new Parameter("@BankAccountNo", invoiceApplyInfo.BankAccountNo),
                        new Parameter("@ContactAddress", invoiceApplyInfo.ContactAddress),
                        new Parameter("@ContactTelephone", invoiceApplyInfo.ContactTelephone),
                        new Parameter("@Receiver", invoiceApplyInfo.Receiver),
                        new Parameter("@Telephone", invoiceApplyInfo.Telephone),
                        new Parameter("@Address", invoiceApplyInfo.Address),
                        new Parameter("@ApplyRemark", invoiceApplyInfo.ApplyRemark),
                        new Parameter("@SaleFilialeId", invoiceApplyInfo.SaleFilialeId),
                        new Parameter("@SalePlatformId", invoiceApplyInfo.SalePlatformId)
                    });
                    db.Execute(false, SQL_DELETE, new[] {
                        new Parameter("@ApplyId", invoiceApplyInfo.ApplyId)
                    });
                    if (detailInfos != null && detailInfos.Count > 0)
                    {
                        foreach (var invoiceApplyDetailInfo in detailInfos)
                        {
                            db.Execute(false, SQL_DETAIL, new[] {
                                new Parameter("@Id", invoiceApplyDetailInfo.Id),
                                new Parameter("@ApplyId", invoiceApplyDetailInfo.ApplyId),
                                new Parameter("@Tradecode", invoiceApplyDetailInfo.Tradecode),
                                new Parameter("@LinkTradeCodes", invoiceApplyDetailInfo.LinkTradeCodes),
                                new Parameter("@PayBalanceAmount", invoiceApplyDetailInfo.PayBalanceAmount),
                                new Parameter("@PayRebateAmount", invoiceApplyDetailInfo.PayRebateAmount),
                                new Parameter("@TotalPayAmount", invoiceApplyDetailInfo.TotalPayAmount)
                            });
                        }
                    }
                    return(db.CompleteTransaction());
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }