alter procedure Asset_wspCheckContract
(
@pi_Action varchar(200),
@pi_InfoId bigint,
@pi_ContractCode varchar(100),
@pi_ContactCode varchar(100),
@pi_SignDate datetime,
@pi_CreateDate datetime,
@pi_BusinessScope varchar(200),
@pi_RendStartDate datetime,
@pi_RendEndDate datetime,
@pi_MonthRental money,
@pi_YeahRental money,
@pi_TotalAmount money,
@pi_ContractStatus int,
@pi_ContractMemo varchar(200),
@pi_EmploymentCode varchar(50),
@pi_CreateUserCode varchar(50),
@pi_HouseAddress varchar(200),
@pi_HouseSquare int,
@pi_HouseTotal varchar(50),
@pi_HouseType varchar(50),
@pi_HouseStruct varchar(50),
@pi_HouseUsing varchar(50),
@pi_HouseMartgage int,
@pi_HouseGoon varchar(50),
@pi_RentChange int,
@pi_RentChangeTime varchar(50),
@pi_RentChangePercent varchar(50),
@pi_RentPlanTime varchar(50),
@pi_PromiseTime varchar(50),
@pi_PromiseMoney money,
@pi_Guarantor varchar(50),
@pi_GuarantorAddress varchar(50),
@pi_GuarantorPost varchar(50),
@pi_GuarantorIDCard varchar(50),
@pi_GuarantorArea varchar(50),
@pi_GuarantorMobile varchar(50),
@pi_GuarantorWorkPlace varchar(100),
@pi_CompanyCode varchar(50),
@pi_CompanyName varchar(50),
@pi_HalfYearRental varchar(50),
@pi_GiveHouseTime varchar(50),
@pi_IsChecked int,
@pi_CheckReason varchar(100),
@po_Status int output,
@po_RetValue varchar(200) output
)
as
if @pi_Action='modify'
begin
update Asset_Contract set
ContactCode=@pi_ContactCode,
SignDate=@pi_SignDate,
CreateDate=@pi_CreateDate,
BusinessScope=@pi_BusinessScope,
RendStartDate=@pi_RendStartDate,
RendEndDate=@pi_RendEndDate,
MonthRental=@pi_MonthRental,
YeahRental=@pi_YeahRental,
TotalAmount=@pi_TotalAmount,
ContractStatus=@pi_ContractStatus,
ContractMemo=@pi_ContractMemo,
CreateUserCode=@pi_CreateUserCode,
HouseAddress=@pi_HouseAddress,
HouseSquare=@pi_HouseSquare,
HouseTotal=@pi_HouseTotal,
HouseType=@pi_HouseType,
HouseStruct=@pi_HouseStruct,
HouseUsing=@pi_HouseUsing,
HouseMartgage=@pi_HouseMartgage,
HouseGoon=@pi_HouseGoon,
RentChange=@pi_RentChange,
RentChangeTime=@pi_RentChangeTime,
RentChangePercent=@pi_RentChangePercent,
RentPlanTime=@pi_RentPlanTime,
PromiseTime=@pi_PromiseTime,
PromiseMoney=@pi_PromiseMoney,
Guarantor=@pi_Guarantor,
GuarantorAddress=@pi_GuarantorAddress,
GuarantorPost=@pi_GuarantorPost,
GuarantorIDCard=@pi_GuarantorIDCard,
GuarantorArea=@pi_GuarantorArea,
GuarantorMobile=@pi_GuarantorMobile,
GuarantorWorkPlace=@pi_GuarantorWorkPlace,
CompanyCode=@pi_CompanyCode,
CompanyName=@pi_CompanyName,
HalfYearRental=@pi_HalfYearRental,
GiveHouseTime=@pi_GiveHouseTime,
IsChecked=@pi_IsChecked,
CheckReason=@pi_CheckReason
where InfoId=@pi_InfoId
set @po_status = 101
set @po_RetValue='审核成功'
--执行生成租金计划的存储过程
IF (@po_status=101)
begin
declare @pt_TotalMonth int --总月数
declare @pt_PlanMonth int --计划月数(需要转换成int)
declare @pt_BiShu int --生成计划笔数(总月数/计划月数)
declare @pt_EveryMoney decimal(18,2) --每笔费用
declare @pt_DateChange int --比较开始日期和签订日期大小
declare @pt_ProEndDate datetime --保证金到期日期
set @pt_TotalMonth = Datediff(month,@pi_RendStartDate,@pi_RendEndDate)
set @pt_PlanMonth = cast(@pi_RentPlanTime as int)
set @pt_ProEndDate=dateadd(month,@pt_PlanMonth,@pi_SignDate)
if(@pt_TotalMonth%@pt_PlanMonth)>0
begin
set @pt_BiShu=(@pt_TotalMonth/@pt_PlanMonth)+1
end
else
begin
set @pt_BiShu=@pt_TotalMonth/@pt_PlanMonth
end
set @pt_EveryMoney=@pi_TotalAmount/@pt_BiShu
if((year(@pi_SignDate)>year(@pi_RendStartDate)) or (year(@pi_SignDate)=year(@pi_RendStartDate)and month(@pi_SignDate)>month(@pi_RendStartDate)))
begin
--插入保证金
insert into Asset_Contract_ChargePlan(ContractCode,ShouldGetDate,CostStartDate,CostEndDate,SumMoney,ChargeType,ChargedItemCode)
values(@pi_ContractCode,@pi_SignDate,@pi_SignDate,@pt_ProEndDate,@pi_PromiseMoney,0,'SF-002')
end
else
begin
exec Asset_spExecuteChargePlanBatch @pi_ContractCode,@pi_SignDate,@pt_PlanMonth,@pt_BiShu,@pt_EveryMoney,1,'',''
--插入保证金
insert into Asset_Contract_ChargePlan(ContractCode,ShouldGetDate,CostStartDate,CostEndDate,SumMoney,ChargeType,ChargedItemCode)
values(@pi_ContractCode,@pi_SignDate,@pi_SignDate,@pt_ProEndDate,@pi_PromiseMoney,0,'SF-002')
end
end
end