Beispiel #1
0
        /// <summary>
        /// 核销处理
        /// </summary>
        public void RHX(RecPay entity, int p_InvoiceID, decimal p_HXAmount, IDBTransAccess sqlTrans)
        {
            try
            {
                string sql = string.Empty;
                //First 处理收付款主表数据
                RecPay entitypay = new RecPay(sqlTrans);//处理收付款主表数据
                entitypay.ID = entity.ID;
                entitypay.SelectByID();

                if (entitypay.HXAmount + p_HXAmount > entitypay.ExAmount)
                {
                    throw new Exception("不能操作,核销金额超过了付款未核金额");
                }
                if (entitypay.HXAmount + p_HXAmount == entitypay.ExAmount)
                {
                    entitypay.HXFlag = (int)YesOrNo.Yes;
                }
                entitypay.HXAmount  += p_HXAmount;
                entitypay.NoHXAmount = entitypay.ExAmount - entitypay.HXAmount;
                this.RUpdate(entitypay, sqlTrans);


                //Second
                InvoiceOperationRule invoicerule   = new InvoiceOperationRule();     //处理发票主表数据
                InvoiceOperation     invoiceentity = new InvoiceOperation(sqlTrans); //发票实体
                invoiceentity.ID = p_InvoiceID;
                invoiceentity.SelectByID();
                if (invoiceentity.PayAmount + p_HXAmount > invoiceentity.TotalAmount)
                {
                    throw new Exception("不能操作,核销金额超过了发票未核金额");
                }
                invoiceentity.PayAmount += p_HXAmount;
                invoicerule.RUpdate(invoiceentity, sqlTrans);



                //Third 增加付款核销明细数据
                RecPayHXDtsRule dtsRule   = new RecPayHXDtsRule();
                RecPayHXDts     dtsentity = new RecPayHXDts(sqlTrans);
                dtsentity.MainID             = entity.ID;
                dtsentity.HXOPID             = entity.MakeOPID;
                dtsentity.HXOPName           = entity.MakeOPName;
                dtsentity.HXDate             = DateTime.Now;
                dtsentity.HXAmount           = p_HXAmount;
                dtsentity.InvoiceNo          = invoiceentity.InvoiceNO;
                dtsentity.InvoiceOperationID = p_InvoiceID;
                dtsRule.RAdd(dtsentity, sqlTrans);//增加明细实体
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 撤销核销处理
        /// </summary>
        public void RHXCancel(RecPay entity, int p_DtsID, IDBTransAccess sqlTrans)
        {
            try
            {
                string sql = string.Empty;
                //First 处理收付款主表数据
                RecPay entitypay = new RecPay(sqlTrans);//处理收付款主表数据
                entitypay.ID = entity.ID;
                entitypay.SelectByID();

                //Second 删除付款核销明细数据
                RecPayHXDtsRule dtsRule   = new RecPayHXDtsRule();
                RecPayHXDts     dtsentity = new RecPayHXDts(sqlTrans);
                dtsentity.ID = p_DtsID;
                dtsentity.SelectByID();
                dtsRule.RDelete(dtsentity, sqlTrans);//删除明细实体


                //First 处理收付款主表数据
                entitypay.HXFlag     = (int)YesOrNo.No;
                entitypay.HXAmount  -= dtsentity.HXAmount;
                entitypay.NoHXAmount = entitypay.ExAmount - entitypay.HXAmount;
                this.RUpdate(entitypay, sqlTrans);


                //Third 处理发票主表数据
                InvoiceOperationRule invoicerule   = new InvoiceOperationRule();     //处理发票主表数据
                InvoiceOperation     invoiceentity = new InvoiceOperation(sqlTrans); //发票实体
                invoiceentity.ID = dtsentity.InvoiceOperationID;
                invoiceentity.SelectByID();

                invoiceentity.PayAmount -= dtsentity.HXAmount;
                if (invoiceentity.PayAmount < 0)
                {
                    throw new BaseException("撤销后数据有误,请检查,发票的核销金额小于0");
                }
                invoicerule.RUpdate(invoiceentity, sqlTrans);
            }
            catch (BaseException)
            {
                throw;
            }
            catch (Exception E)
            {
                throw new BaseException(E.Message);
            }
        }