//是否本月
INT32 CmpCurMonth(UINT32 nDate, UINT32 nTime)
{
    INT32 nRet = 1;
    //该票是否在本月内???????
    UINT32 curYear, curMonth, curDay;
    UINT32 tmpYear, tmpMonth, tmpDay;
    TDateTime::CurrentDateTime().DecodeDate(curYear, curMonth, curDay);
    DBG_PRINT(("curYear=%u, curMonth = %u, curDay = %u", curYear, curMonth, curDay));
    TDateTime invDate(nDate, nTime);
    invDate.DecodeDate(tmpYear, tmpMonth, tmpDay);
    DBG_PRINT(("tmpYear=%u, tmpMonth = %u, tmpDay = %u", tmpYear, tmpMonth, tmpDay));

    if (tmpYear < curYear)
    {
        DBG_PRINT(("tmpYear < curYear"));
        nRet = -1;
    }
    else if (tmpYear == curYear)
    {
        if (tmpMonth < curMonth)
        {
            DBG_PRINT(("tmpMonth < curMonth"));
            nRet = -1;
        }
        else if (tmpMonth == curMonth)
        {
            DBG_PRINT(("tmpMonth == curMonth"));
            nRet = 0;
        }
    }

    return nRet;
}
예제 #2
0
INT32 CJSKMakeInvoice::MakeInvAuthority(CInvHead *pInvHead, string& strErr)
{
	INT32 retcode = JSK_SUCCESS;
	INT8 tmpBuff[32];
	UINT8 sDecBuff[MAX_DATETIME_LEN+1];
	INT8 sqlbuf[128];
	INT32 errcode = 0;
	memset(sqlbuf, 0, sizeof(sqlbuf));

	UINT32 uCurDate = 0;
	UINT32 uCurTime = 0;
	uCurDate = pInvHead->m_kprq;
	uCurTime = pInvHead->m_kpsj;
	DBG_PRINT(("uCurDate = %u", uCurDate));
	DBG_PRINT(("uCurTime = %u", uCurTime));

	switch(pInvHead->m_kplx)
	{
	case JSK_NORMAL_INV:
// 		{
// 			//离线锁死日(判断当前时间是否超过离线锁死日)
// 			
// 			//离线开票限定时长(当前时间与第一张未上传的发票时间比对)
// 			CInvServ invServ;
// 			invServ.Requery();
// 			if(invServ.LoadOneRecord() == SQLITE_OK)
// 			{
// 				DBG_PRINT(("invServ.m_issueDate = %u", invServ.m_issueDate));
// 				DBG_PRINT(("invServ.m_issueTime = %u", invServ.m_issueTime));
// 				DBG_PRINT(("g_globalArgLib->m_invKind->m_Lxkjsj = %u", g_globalArgLib->m_invKind->m_Lxkjsj));
// 				TDateTime upDateTime(invServ.m_issueDate, invServ.m_issueTime);
// 				upDateTime = upDateTime.HourAdd(upDateTime, g_globalArgLib->m_invKind->m_Lxkjsj);
// 				DBG_PRINT(("upDateTime = %s", upDateTime.FormatString(YYYYMMDDHHMMSS).c_str()));
// 				DBG_PRINT(("curDateTime = %s", curDateTime.FormatString(YYYYMMDDHHMMSS).c_str()));
// 				if(curDateTime >= upDateTime)
// 				{
// 					strErr = "离线开具限定时长超限!";
// 					return JSK_FAILURE;
// 				}
// 			}
// 			
// 			//离线开票限定正数累计金额
// 			if(nSum + g_globalArgLib->m_InvServSum > g_globalArgLib->m_invKind->m_maxSum)
// 			{
// 				strErr = "离线累计金额超限!";
// 				return JSK_FAILURE;
// 			}
// 		}
		break;
	case JSK_RETURN_INV:
		{
			sprintf(sqlbuf, "where FPDM='%s' and FPHM=%u", pInvHead->m_yfpdm.c_str(), pInvHead->m_yfphm);
			DBG_PRINT(("sqlbuf = %s", sqlbuf));
			CRtInv tmpRtInv;
			tmpRtInv.m_filter.append(sqlbuf);
			tmpRtInv.Requery();
			errcode = tmpRtInv.LoadOneRecord();
			if(errcode == SQLITE_OK)
			{
				retcode = JSK_COMMON_ERR_NO;
				strErr = "已开过负票,不能再次开具!";
				return retcode;
			}
			
			memset(sDecBuff, 0, sizeof(sDecBuff));
			retcode = CJSKInfoFunc::GetJSPSendTime(sDecBuff, strErr);
			if( retcode != JSK_SUCCESS )
			{
				return retcode;
			}
			TDateTime sDecDate((INT8 *)sDecBuff, DATETIME_POS);
			CInvHead tmpInvHead;
			tmpInvHead.m_filter.append(sqlbuf);
			tmpInvHead.Requery();
			errcode = tmpInvHead.LoadOneRecord();
			if(errcode != SQLITE_OK)
			{
				tmpInvHead.m_fpdm = pInvHead->m_yfpdm;
				tmpInvHead.m_fphm = pInvHead->m_yfphm;
				retcode = CJSKInfoFunc::GetInvDetailInfoNO(&tmpInvHead, strErr);
				if(retcode != JSK_SUCCESS)
				{
					return retcode;
				}
				
				if(tmpInvHead.Save() != SUCCESS)
				{
					DBG_PRINT(("InvHead Save Error!"));
				}
			}

			if(tmpInvHead.m_kplx != JSK_NORMAL_INV)
			{
				retcode = JSK_COMMON_ERR_NO;
				strErr = "原发票非正数发票,不能开具负票!";
				return retcode;
			}

			if(tmpInvHead.m_kphjje != pInvHead->m_kphjje)
			{
				retcode = JSK_COMMON_ERR_NO;
				strErr = "负票金额与原发票不一致!";
				return retcode;
			}

// 			TDateTime invDate(tmpInvHead.m_kprq, tmpInvHead.m_kpsj);
// 			DBG_PRINT(("invDate = %s", invDate.FormatString(YYYYMMDDHHMMSS).c_str()));
// 			DBG_PRINT(("sDecDate = %s", sDecDate.FormatString(YYYYMMDDHHMMSS).c_str()));
// 			if(invDate >= sDecDate)
// 			{
// 				retcode = JSK_COMMON_ERR_NO;
// 				strErr = "原发票未抄报,不能开具负票!";
// 				return retcode;
// 			}
		}
		break;
	case JSK_WASTE_INV:
		break;
	case JSK_WASTE_NOR:
	case JSK_WASTE_RET:
		{
			memset(sDecBuff, 0, sizeof(sDecBuff));
			retcode = CJSKInfoFunc::GetJSPSendTime(sDecBuff, strErr);
			if( retcode != JSK_SUCCESS )
			{
				return retcode;
			}
			TDateTime sDecDate((INT8 *)sDecBuff, DATETIME_POS);

			memset(sDecBuff, 0, sizeof(sDecBuff));
			sprintf((INT8 *)sDecBuff, "%08u%06u", pInvHead->m_kprq, pInvHead->m_kpsj);
			TDateTime invDate((INT8 *)sDecBuff, DATETIME_POS);
			if(invDate < sDecDate)
			{
				retcode = JSK_COMMON_ERR_NO;
				strErr = "原发票已抄报,不能作废";
				return retcode;
			}
		}
		break;
	default:
		break;
	}

	
	return JSK_SUCCESS;
}