INT32 CInvHead::Load() { DBG_ENTER("CInvHead::Load"); DBG_PRINT(("进入CInvHead::Load函数")); //释放链表所占空间 DelList(); //查询INV_HEAD表 CTable::Requery(); INT32 returnVal = LoadOneRecord(); if (returnVal == SQLITE_OK) { DBG_PRINT(("NO, %d", m_no)); DBG_PRINT(("m_fpdm, %s", m_fpdm.c_str())); DBG_PRINT(("m_fphm, %d", m_fphm)); DBG_PRINT(("m_kprq, %lu", m_kprq)); DBG_PRINT(("m_kpsj, %lu", m_kpsj)); DBG_PRINT(("m_kplx, %d", m_kplx)); DBG_PRINT(("m_kphjje, %lld", m_kphjje)); DBG_PRINT(("m_yfphm, %d", m_yfphm)); DBG_PRINT(("m_fkdw, %s", m_fkdw.c_str())); DBG_PRINT(("m_payerCode, %s", m_payerCode.c_str())); DBG_PRINT(("m_sky, %s", m_sky.c_str())); // DBG_PRINT(("m_skyid, %u", m_skyid)); DBG_PRINT(("m_fwm, %s", m_fwm.c_str())); // DBG_PRINT(("m_ptype, %d", m_ptype)); //DBG_NPRINT_HEX(m_fCode, 8); DBG_PRINT(("m_sphsl, %d", m_sphsl)); DBG_PRINT(("BACKUP1, %s", m_backup1.c_str())); // DBG_PRINT(("BACKUP2, %s", m_backup2.c_str())); // DBG_PRINT(("BACKUP3, %s", m_backup3.c_str())); } else if (returnVal == SQLITE_DONE) { DBG_PRINT((" CInvHead has no matched record! errorcode: %d", returnVal)); return returnVal; } else { DBG_PRINT(("errorcode: %d", returnVal)); return returnVal; } m_kpje = m_kphjje - m_kpse; //查询INV_DET表 INT8 chFilter[256]; memset((void *)chFilter, 0x00, sizeof(chFilter)); sprintf(chFilter, "where FPDM = '%s' and FPHM = %u", m_fpdm.c_str(), m_fphm); DBG_PRINT(("chFilter = %s", chFilter)); m_pInvDet->m_filter = chFilter; m_pInvDet->Requery(); INT32 errorcode = m_pInvDet->MoveFirst(); if (errorcode != SQLITE_ROW) { if ((errorcode == SQLITE_DONE)&&(m_sphsl==0)) //没有明细 { m_pInvDet->MoveEnd(); return SQLITE_OK; } else { DBG_PRINT(("errorcode: %d", errorcode)); m_pInvDet->MoveEnd(); return errorcode; //可能返回SQLITE_DONE,或其它错误码 } } CInvDet *p; while (errorcode == SQLITE_ROW) { // p = new CInvDet; p = p->GetNewInvDet();//从静态数组获取一个可用的CInvDet对象 p->m_no = m_pInvDet->m_no; p->m_fpdm = m_pInvDet->m_fpdm; p->m_fphm = m_pInvDet->m_fphm; p->m_kprq = m_pInvDet->m_kprq; p->m_kpsj = m_pInvDet->m_kpsj; p->m_kplx = m_pInvDet->m_kplx; p->m_sphxh = m_pInvDet->m_sphxh; p->m_spbm = m_pInvDet->m_spbm; p->m_spmc = m_pInvDet->m_spmc; p->m_spdj = m_pInvDet->m_spdj; p->m_spsl = m_pInvDet->m_spsl; p->m_spje = m_pInvDet->m_spje; p->m_spdw = m_pInvDet->m_spdw; p->m_sl = m_pInvDet->m_sl; p->m_spse = m_pInvDet->m_spse; p->m_property = m_pInvDet->m_property; p->m_dj = m_pInvDet->m_dj; p->m_je = m_pInvDet->m_je; InsertNode(p); //插入节点 DBG_PRINT(("============================")); DBG_PRINT(("NO, %d", m_pInvDet->m_no)); DBG_PRINT(("m_fpdm, %s", m_pInvDet->m_fpdm.c_str())); DBG_PRINT(("m_fphm, %d", m_pInvDet->m_fphm)); DBG_PRINT(("m_sphxh, %d", m_pInvDet->m_sphxh)); DBG_PRINT(("m_kprq, %lu", m_pInvDet->m_kprq)); DBG_PRINT(("m_kpsj, %lu", m_pInvDet->m_kpsj)); DBG_PRINT(("m_spbm, %s", m_pInvDet->m_spbm.c_str())); DBG_PRINT(("m_spmc, %s", m_pInvDet->m_spmc.c_str())); DBG_PRINT(("m_spdj, %f", m_pInvDet->m_spdj)); DBG_PRINT(("m_spsl, %f", m_pInvDet->m_spsl)); DBG_PRINT(("m_spje, %lld", m_pInvDet->m_spje)); DBG_PRINT(("m_spse, %lld", m_pInvDet->m_spse)); DBG_PRINT(("m_spdw, %s", m_pInvDet->m_spdw.c_str())); // DBG_PRINT(("PRICE, %u", m_pInvDet->m_dpNo)); errorcode = m_pInvDet->MoveNext(); } m_pInvDet->MoveEnd(); //m_db->MutexUnlock(); if (errorcode==SQLITE_DONE) { DBG_PRINT(("退出CInvHead::Load函数")); return SQLITE_OK; } DBG_PRINT(("退出CInvHead::Load函数")); return errorcode; }
UINT8 SimpleMakeNormalInv(SaleData &tmpSaleData,string &strErr) { UINT8 ret; CInvDet *invDet = NULL; CInvHead invHead; tmpSaleData.m_smallInvInfo = &invHead; UINT32 nCurDate = TDateTime::CurrentDateTime().FormatInt(YYYYMMDD); UINT32 nCurTime = TDateTime::CurrentDateTime().FormatInt(HHMMSS); INT64 tmpDJ=0; INT64 moneyTaxSum=0; //组装正票 //组装发票头 //tmpSaleData.m_smallInvInfo->m_fphm = g_globalArg->m_curInvVol->m_ieno + 1 - // g_globalArg->m_curInvVol->m_remain; /**< 发票号码 */ ret = SALE_GetCurInv(g_globalArg->m_curInvVol,strErr); DBG_PRINT(("strErr= %s",strErr.c_str())); if (ret ==FAILURE) { DBG_PRINT(("获取当前发票号码错误:%s",strErr.c_str())); return ret; } tmpSaleData.m_smallInvInfo->m_fphm = g_globalArg->m_curInvVol->m_curInvNo; tmpSaleData.m_smallInvInfo->m_fpdm = g_globalArg->m_curInvVol->m_code; /**< 发票代码简称 */ tmpSaleData.m_smallInvInfo->m_kplx = NORMAL_INV; //开票类型 tmpSaleData.m_smallInvInfo->m_yfphm = 0; //原发票号码 tmpSaleData.m_smallInvInfo->m_yfpdm = ""; //原发票号码 tmpSaleData.m_smallInvInfo->m_fplb = atoi(g_globalArg->m_invKind->m_pzCode.c_str()); //发票种类 tmpSaleData.m_smallInvInfo->m_fkdw = "个人"; //付款人名称 tmpSaleData.m_smallInvInfo->m_fkdwsh = "012345678901234"; tmpSaleData.m_smallInvInfo->m_sky = g_globalArg->m_operator->m_name; //操作员名称 // tmpSaleData.m_smallInvInfo->m_opId = g_globalArg->m_operator->m_opId; //操作员id // tmpSaleData.m_smallInvInfo->m_uID = 0; //纳税户名称ID号 // tmpSaleData.m_smallInvInfo->m_ptype = 0; //付款方式 tmpSaleData.m_smallInvInfo->m_sphsl = 3;//当前发票总商品行加1 tmpSaleData.m_smallInvInfo->m_kphjje = (INT64)(3.00 * SUM_EXTENSION);//当前发票总金额 tmpSaleData.m_smallInvInfo->m_backup1 = ""; //备用字段1 // tmpSaleData.m_smallInvInfo->m_backup2 = ""; //备用字段2 // tmpSaleData.m_smallInvInfo->m_backup3 = ""; //备用字段3 //发票明细 for(UINT8 i = 1; i<4; i++) { // invDet = new CInvDet; invDet = invDet->GetNewInvDet();//从静态数组获取一个可用的CInvDet对象 DBG_ASSERT_EXIT((invDet != NULL), (" invDet == NULL!")); invDet->m_fpdm = tmpSaleData.m_smallInvInfo->m_fpdm; invDet->m_fphm = tmpSaleData.m_smallInvInfo->m_fphm; // invDet->m_sphxh = i; invDet->m_kprq = nCurDate; invDet->m_kpsj = nCurTime; invDet->m_kplx = NORMAL_INV; invDet->m_sky = g_globalArg->m_operator->m_name; invDet->m_spbm = "0000000000001"; invDet->m_sphxh = i; invDet->m_spmc = "测试商品1"; // invDet->m_taxId = 1; //非税控只允许税目1 invDet->m_spsl = 1.0; //保存四舍五入后的值 invDet->m_dotNum = 0; invDet->m_spdj = (double)1.00; invDet->m_spje = (INT64)(1.00*SUM_EXTENSION); invDet->m_sl = 0.03; invDet->m_spse=tmpSaleData.CountTax(invDet->m_spje, (UINT32)(invDet->m_sl*SUM_EXTENSION)); //商品税额 invDet->m_je= invDet->m_spje - invDet->m_spse; //商品金额(不含税) invDet->m_spdw = "个"; //商品单位 tmpDJ = double2int(invDet->m_spdj*SUM_EXTENSION); DBG_PRINT(("tmpDJ==%lld ", tmpDJ)); tmpDJ -=tmpSaleData.CountTax(double2int(invDet->m_spdj*SUM_EXTENSION), (UINT32)(invDet->m_sl*SUM_EXTENSION)); DBG_PRINT(("tmpDJ==%lld ", tmpDJ)); invDet->m_dj= (double)(tmpDJ*1.0)/SUM_EXTENSION; //商品单价(不含税) invDet->m_je= invDet->m_spje-invDet->m_spse; //商品金额(不含税) moneyTaxSum += invDet->m_spse; invDet->m_property = DETAIL_GENERAL_GOODS; invDet->m_backup = ""; tmpSaleData.m_smallInvInfo->InsertNode(invDet); //插入节点 } //当前发票累计税额增加 tmpSaleData.m_smallInvInfo->m_kpse = moneyTaxSum; DBG_PRINT(("当前发票累计税额 tmpSaleData.m_smallInvInfo->m_kpse = %lld", tmpSaleData.m_smallInvInfo->m_kpse)); moneyTaxSum = 0; ret = tmpSaleData.MakeInvoiceHandle(PRINT, INV_ROLL_PROC); tmpSaleData.m_smallInvInfo->DelList(); tmpSaleData.m_smallInvInfo = NULL; if (ret != SUCCESS) { if (ret==DB_FULL) { DBG_RETURN(DB_FULL); } else if (ret==HAVE_ROLLED) { DBG_RETURN(HAVE_ROLLED); } else { DBG_RETURN(ret); } } DBG_RETURN(SUCCESS); }
void CDataTransformFunc::Data2InvHead(CDataInvHead *pDataInvHead, CInvHead *pInvHead) { DBG_PRINT(("Data2InvHead Begin")); pInvHead->m_fpdm = pDataInvHead->m_fpdm; /**< 发票代码 */ pInvHead->m_fphm = pDataInvHead->m_fphm; /**< 发票号码 */ pInvHead->m_kprq = pDataInvHead->m_kprq; /**< 开票日期 */ pInvHead->m_kpsj = pDataInvHead->m_kpsj; /**< 开票时间 */ pInvHead->m_kplx = pDataInvHead->m_kplx; /**< 开票类型 */ pInvHead->m_kphjje = pDataInvHead->m_kphjje; /**< 开票合计金额(含税) */ pInvHead->m_yfpdm = pDataInvHead->m_yfpdm; /**< 原发票代码 */ pInvHead->m_yfphm = pDataInvHead->m_yfphm; /**< 原发票号码 */ pInvHead->m_fkdw = pDataInvHead->m_fkdw; /**< 付款单位 */ pInvHead->m_payerCode = pDataInvHead->m_payerCode; /**< 付款单位税号 */ pInvHead->m_sky = pDataInvHead->m_sky; /**< 收款员 */ pInvHead->m_sphsl = pDataInvHead->m_sphsl; /**< 商品行数量 */ pInvHead-> m_fwm = pDataInvHead->m_fwm; /**< 防伪税控吗 */ pInvHead->m_fplb = pDataInvHead->m_fplb; /**< 发票类别 */ pInvHead->m_scbz = pDataInvHead->m_scbz; /**< 上传标志 */ pInvHead->m_fpsyh = pDataInvHead->m_fpsyh; /**< 发票索引号*/ pInvHead->m_zfsj = pDataInvHead->m_zfsj; /**< 作废时间 */ pInvHead->m_casign = pDataInvHead->m_casign; /**< CA签名*/ pInvHead->m_backup1 = pDataInvHead->m_backup1; /**< 备用1 */ pInvHead->m_backup2 = pDataInvHead->m_backup2; /**< 备用2 */ pInvHead->m_kpse = pDataInvHead->m_kpse; /**< 税额*/ pInvHead->m_kpje = pDataInvHead->m_kpje; /**< 金额(不含税额)*/ pInvHead->m_fplxdm = pDataInvHead->m_fplxdm; /**< 发票类型代码 */ pInvHead->m_zfbz = pDataInvHead->m_zfbz; /**< 作废标志*/ pInvHead->m_hyfl = pDataInvHead->m_hyfl; /**< 行业分类 */ pInvHead->m_fpzl = pDataInvHead->m_fpzl; /**< 发票种类 默认为"c" */ pInvHead->m_gfdzdh = pDataInvHead->m_gfdzdh; /**< 购方地址电话 */ pInvHead->m_gfyhzh = pDataInvHead->m_gfyhzh; /**< 购方银行账号 */ pInvHead->m_jqbh = pDataInvHead->m_jqbh; /**< 机器编号 */ pInvHead->m_zyspmc = pDataInvHead->m_zyspmc; /**< 主要商品名称 */ pInvHead->m_bsq = pDataInvHead->m_bsq; /**< 报税期 */ pInvHead->m_sksbbh = pDataInvHead->m_sksbbh; /**< 金税盘编号 */ pInvHead->m_xfmc = pDataInvHead->m_xfmc; /**< 销方名称 */ pInvHead->m_xfsh = pDataInvHead->m_xfsh; /**< 销方税号 */ pInvHead->m_xfdzdh = pDataInvHead->m_xfdzdh; /**< 销方地址电话 */ pInvHead->m_xfyhzh = pDataInvHead->m_xfyhzh; /**< 销方银行账号 */ pInvHead->m_fhr = pDataInvHead->m_fhr; /**< 复核人 */ pInvHead->m_qdbz = pDataInvHead->m_qdbz; /**< 清单标志 */ pInvHead->m_zskl = pDataInvHead->m_zskl; /**< 证书口令 */ pInvHead->m_CurTime = pDataInvHead->m_CurTime; /**< 当前时间*/ CInvDet *pInvDet = NULL; pInvHead->DelList(); vector<CDataInvDet>::iterator iter; for (iter=pDataInvHead->m_gvector.begin(); iter!=pDataInvHead->m_gvector.end(); ++iter) { pInvDet = pInvDet->GetNewInvDet(); pInvDet->m_fpdm = iter->m_fpdm; /**< 发票代码 */ pInvDet->m_fphm = iter->m_fphm; /**< 发票号码 */ pInvDet->m_kprq = iter->m_kprq; /**< 开票日期 */ pInvDet->m_kpsj = iter->m_kpsj; /**< 开票时间 */ pInvDet->m_kplx = iter->m_kplx; /**< 开票类型 */ pInvDet->m_opid = iter->m_opid; /**< 操作员id */ pInvDet->m_sky = iter->m_sky; /**< 收款员 */ pInvDet->m_sphxh = iter->m_sphxh; /**< 商品行序号,从1开始 */ pInvDet->m_spbm = iter->m_spbm; /**< 商品编码 */ pInvDet->m_spmc = iter->m_spmc; /**< 商品名称 */ pInvDet->m_spdj = iter->m_spdj; /**< 商品单价(含税) */ pInvDet->m_spsl = iter->m_spsl; /**< 商品数量 */ pInvDet->m_spje = iter->m_spje; /**< 商品金额(含税) */ pInvDet->m_sl = iter->m_sl; /**< 税率 */ pInvDet->m_property = iter->m_property; /**< 商品行属性 */ pInvDet->m_spdw = iter->m_spdw; /**< 单位 */ pInvDet->m_ggxh = iter->m_ggxh; /**< 规格型号 */ pInvDet->m_spse = iter->m_spse; /**< 商品税额 */ pInvDet->m_dj = iter->m_dj; /**< 商品单价(不含税) */ pInvDet->m_je = iter->m_je; /**< 商品金额(不含税) */ pInvDet->m_dotNum = iter->m_dotNum; /**< 数量四舍五入后的小数位数 */ pInvDet->m_backup = iter->m_backup; /**< 备用 */ pInvDet->m_hsbz = iter->m_hsbz; /**< 含税价标志(1:单价含税 0:单价不含税) */ DBG_PRINT(("m_sphxh = %u", pInvDet->m_sphxh)); DBG_PRINT(("m_spmc = %s", pInvDet->m_spmc.c_str())); DBG_PRINT(("m_spdj = %.3f", pInvDet->m_spdj)); DBG_PRINT(("m_spsl = %.3f", pInvDet->m_spsl)); DBG_PRINT(("m_spje = %lld", pInvDet->m_spje)); DBG_PRINT(("m_sl = %.3f", pInvDet->m_sl)); DBG_PRINT(("m_spse = %lld", pInvDet->m_spse)); DBG_PRINT(("m_dj = %.3f", pInvDet->m_dj)); DBG_PRINT(("m_je = %lld", pInvDet->m_je)); pInvHead->InsertNode(pInvDet); pInvDet = NULL; } return; }
INT32 CFpkj::XmlParse(XMLParse *parse, CInvHead *pInvInfo) { UINT8 i = 0; parse->LocateNodeByName(parse->m_RootElement, "body"); parse->m_parentElement[1] = parse->m_Child; parse->LocateNodeByName(parse->m_parentElement[1], "input"); parse->m_parentElement[2] = parse->m_Child; parse->LocateNodeByName(parse->m_parentElement[2], "jqbh"); m_ywxml_gy.m_jqbh = parse->GetText(); //税控收款机编号 DBG_PRINT(("m_ywxml_gy.m_jqbh == %s", m_ywxml_gy.m_jqbh.c_str())); pInvInfo->m_jqbh = m_ywxml_gy.m_jqbh; DBG_PRINT(("pInvInfo->m_jqbh == %s", pInvInfo->m_jqbh.c_str())); parse->LocateNodeByName(parse->m_parentElement[2], "zskl"); pInvInfo->m_zskl = parse->GetText(); //证书口令 DBG_PRINT(("pInvInfo->m_zskl == %s", pInvInfo->m_zskl.c_str())); parse->LocateNodeByName(parse->m_parentElement[2], "xhdwdm"); m_ywxml_gy.m_nsrsbh = parse->GetText(); DBG_PRINT(("m_ywxml_gy.nsrsbh == %s", m_ywxml_gy.m_nsrsbh.c_str())); pInvInfo->m_xfsh = parse->GetText(); DBG_PRINT(("pInvInfo->m_xfsh == %s", pInvInfo->m_xfsh.c_str())); parse->LocateNodeByName(parse->m_parentElement[2], "xhdwmc"); pInvInfo->m_xfmc = parse->GetText(); DBG_PRINT(("pInvInfo->m_xfmc == %s", pInvInfo->m_xfmc.c_str())); parse->LocateNodeByName(parse->m_parentElement[2], "sksbbh"); m_ywxml_gy.m_sksbbh = parse->GetText(); DBG_PRINT(("m_ywxml_gy.sksbbh == %s", m_ywxml_gy.m_sksbbh.c_str())); pInvInfo->m_sksbbh = m_ywxml_gy.m_sksbbh; DBG_PRINT(("pInvInfo->m_sksbbh == %s", pInvInfo->m_sksbbh.c_str())); parse->LocateNodeByName(parse->m_parentElement[2], "sksbkl"); m_ywxml_gy.m_sksbkl = parse->GetText(); DBG_PRINT(("m_ywxml_gy.sksbkl == %s", m_ywxml_gy.m_sksbkl.c_str())); parse->LocateNodeByName(parse->m_parentElement[2], "fplxdm"); m_ywxml_gy.m_fplxdm = parse->GetText(); pInvInfo->m_fplxdm = m_ywxml_gy.m_fplxdm; DBG_PRINT(("m_ywxml_gy.fplxdm == %s", m_ywxml_gy.m_fplxdm.c_str())); parse->LocateNodeByName(parse->m_parentElement[2], "kplx"); pInvInfo->m_kplx = (UINT8)atoi(parse->GetText().c_str()); DBG_PRINT(("pInvInfo->m_kplx == %u", pInvInfo->m_kplx)); // parse->LocateNodeByName(parse->m_parentElement[2], "hyfl"); // pInvInfo->m_hyfl = parse->GetText(); // DBG_PRINT(("hyfl== %s", pInvInfo->m_hyfl.c_str())); parse->LocateNodeByName(parse->m_parentElement[2], "ghdwdm"); pInvInfo->m_payerCode = parse->GetText(); CJSKMakeInvoice::FilterSpace(pInvInfo->m_payerCode); if(pInvInfo->m_payerCode == "") pInvInfo->m_payerCode = "000000000000000"; DBG_PRINT(("pInvInfo->m_payerCode == %s", pInvInfo->m_payerCode.c_str())); parse->LocateNodeByName(parse->m_parentElement[2], "ghdwmc"); pInvInfo->m_fkdw = parse->GetText(); CJSKMakeInvoice::FilterSpace(pInvInfo->m_fkdw); DBG_PRINT(("pInvInfo->m_fkdw == %s", pInvInfo->m_fkdw.c_str())); parse->LocateNodeByName(parse->m_parentElement[2], "sfxm"); parse->m_parentElement[3] = parse->m_Child; pInvInfo->m_sphsl = atoi(parse->GetAttr("count").c_str()); //解析XML后得到商品明细行数 DBG_PRINT(("pInvInfo->m_sphsl == %u", pInvInfo->m_sphsl)); CInvDet* pInvDet = NULL; for (i=0; i<pInvInfo->m_sphsl; i++) { pInvDet = pInvDet->GetNewInvDet(); //从静态数组获取一个可用的CInvDet对象 DBG_ASSERT_EXIT((pInvDet != NULL), (" pInvDet == NULL!")); pInvDet->m_sphxh = i+1; //得到group节点 parse->LocateNodeByName(parse->m_parentElement[3], "group", i); parse->m_parentElement[4] = parse->m_Child; parse->LocateNodeByName(parse->m_parentElement[4], "xm"); pInvDet->m_spmc = parse->GetText(); CJSKMakeInvoice::FilterSpace(pInvDet->m_spmc); DBG_PRINT(("pInvDet->m_spmc == %s", pInvDet->m_spmc.c_str())); parse->LocateNodeByName(parse->m_parentElement[4], "dj"); pInvDet->m_dj = atof(parse->GetText().c_str()); DBG_PRINT(("pInvDet->m_dj == %lf", pInvDet->m_dj)); parse->LocateNodeByName(parse->m_parentElement[4], "sl"); pInvDet->m_spsl = atof(parse->GetText().c_str()); DBG_PRINT(("pInvDet->m_spsl == %lf", pInvDet->m_spsl)); parse->LocateNodeByName(parse->m_parentElement[4], "je"); pInvDet->m_je =double2int(atof(parse->GetText().c_str())*SUM_EXTENSION); DBG_PRINT(("pInvDet->m_je == %lld", pInvDet->m_je)); parse->LocateNodeByName(parse->m_parentElement[4], "zsl"); pInvDet->m_sl = (float)atof(parse->GetText().c_str()); DBG_PRINT(("pInvDet->m_sl == %f", pInvDet->m_sl)); parse->LocateNodeByName(parse->m_parentElement[4], "se"); DBG_PRINT(("pInvDet->m_spse == %s", parse->GetText().c_str())); pInvDet->m_spse = double2int(atof(parse->GetText().c_str())*SUM_EXTENSION); DBG_PRINT(("pInvDet->m_spse == %lld", pInvDet->m_spse)); parse->LocateNodeByName(parse->m_parentElement[4], "hsdj"); pInvDet->m_spdj = atof(parse->GetText().c_str()); DBG_PRINT(("pInvDet->m_spdj == %lf", pInvDet->m_spdj)); parse->LocateNodeByName(parse->m_parentElement[4], "hsje"); pInvDet->m_spje = double2int(atof(parse->GetText().c_str())*SUM_EXTENSION); DBG_PRINT(("pInvDet->m_spje == %lld", pInvDet->m_spje)); pInvInfo->InsertNode(pInvDet); pInvDet = NULL; } parse->LocateNodeByName(parse->m_parentElement[2], "hjje"); pInvInfo->m_kpje = double2int(atof(parse->GetText().c_str())*SUM_EXTENSION); DBG_PRINT(("pInvInfo->m_kpje == %lld", pInvInfo->m_kpje)); parse->LocateNodeByName(parse->m_parentElement[2], "hjse"); DBG_PRINT(("pInvDet->m_spse == %s", parse->GetText().c_str())); pInvInfo->m_kpse = double2int(atof(parse->GetText().c_str())*SUM_EXTENSION); DBG_PRINT(("pInvInfo->m_kpse == %lld", pInvInfo->m_kpse)); parse->LocateNodeByName(parse->m_parentElement[2], "jshj"); pInvInfo->m_kphjje = double2int(atof(parse->GetText().c_str())*SUM_EXTENSION); DBG_PRINT(("pInvInfo->m_kphjje == %lld", pInvInfo->m_kphjje)); parse->LocateNodeByName(parse->m_parentElement[2], "bz"); pInvInfo->m_backup1 = parse->GetText(); CJSKMakeInvoice::FilterSpace(pInvInfo->m_backup1); DBG_PRINT(("pInvInfo->m_backup1 == %s", pInvInfo->m_backup1.c_str())); parse->LocateNodeByName(parse->m_parentElement[2], "skr"); pInvInfo->m_sky = parse->GetText(); CJSKMakeInvoice::FilterSpace(pInvInfo->m_sky); DBG_PRINT(("pInvInfo->m_sky == %s", pInvInfo->m_sky.c_str())); // parse->LocateNodeByName(parse->m_parentElement[2], "kpr"); // pInvInfo->m_sky = parse->GetText(); // DBG_PRINT(("pInvInfo->m_sky == %s", pInvInfo->m_sky.c_str())); parse->LocateNodeByName(parse->m_parentElement[2], "yfpdm"); pInvInfo->m_yfpdm = parse->GetText(); DBG_PRINT(("pInvInfo->m_yfpdm == %s", pInvInfo->m_yfpdm.c_str())); parse->LocateNodeByName(parse->m_parentElement[2], "yfphm"); pInvInfo->m_yfphm = atoi(parse->GetText().c_str()); DBG_PRINT(("pInvInfo->m_yfphm == %u", pInvInfo->m_yfphm)); return SUCCESS; }
INT32 CFpcx::XmlParse() { UINT8 i = 0; UINT8 j = 0; UINT8 fpzt = 0; //添加body节点 m_pXmlParse.LocateNodeByName(m_pXmlParse.m_RootElement, "body"); m_pXmlParse.m_parentElement[1] = m_pXmlParse.m_Child; m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[1], "output"); m_pXmlParse.m_parentElement[2] = m_pXmlParse.m_Child; m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[2], "returncode"); m_retInfo.m_retCode = m_pXmlParse.GetText(); DBG_PRINT(("returncode : %s", m_retInfo.m_retCode.c_str())); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[2], "returnmsg"); m_retInfo.m_retMsg = m_pXmlParse.GetText(); DBG_PRINT(("returnmsg : %s", m_retInfo.m_retMsg.c_str())); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[2], "fpxx"); m_pXmlParse.m_parentElement[3] = m_pXmlParse.m_Child; m_InvCOunt = atoi(m_pXmlParse.GetAttr("count").c_str()); for (i=0; i<m_InvCOunt; i++) { m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[3], "group", i); m_pXmlParse.m_parentElement[4] = m_pXmlParse.m_Child; m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "fpdm"); m_InvInfo.m_fpdm = m_pXmlParse.GetText(); DBG_PRINT(("m_InvInfo.m_fpdm : %s", m_InvInfo.m_fpdm.c_str())); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "fphm"); m_InvInfo.m_fphm = atoi(m_pXmlParse.GetText().c_str()); DBG_PRINT(("m_InvInfo.m_fphm : %u", m_InvInfo.m_fphm)); //发票状态 m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "fpzt"); fpzt = atoi(m_pXmlParse.GetText().c_str()); switch(fpzt) { case 0: m_InvInfo.m_kplx = NORMAL_INV; break; case 1: m_InvInfo.m_kplx = RETURN_INV; break; case 2: m_InvInfo.m_kplx = WASTE_INV; break; case 3: m_InvInfo.m_kplx = WASTE_NOR; break; case 4: m_InvInfo.m_kplx = WASTE_RET; break; } m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "scbz"); m_InvInfo.m_scbz = (UINT8)atoi(m_pXmlParse.GetText().c_str()); DBG_PRINT(("m_InvInfo.m_scbz : %u", m_InvInfo.m_scbz)); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "kprq"); m_InvInfo.m_kprq = atoi(m_pXmlParse.GetText().c_str()); DBG_PRINT(("m_InvInfo.m_kprq : %u", m_InvInfo.m_kprq)); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "kpsj"); m_InvInfo.m_kpsj = atoi(m_pXmlParse.GetText().c_str()); DBG_PRINT(("m_InvInfo.m_kpsj : %u", m_InvInfo.m_kpsj)); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "skm"); m_InvInfo.m_fwm = m_pXmlParse.GetText(); DBG_PRINT(("m_InvInfo.m_fwm : %s", m_InvInfo.m_fwm.c_str())); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "sksbbh"); //税控设备编号 m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "skdwmc"); //收款单位名称 m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "xhdwdm"); //销货单位识别号 m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "xhdwmc"); //销货单位名称 //购货单位识别号 m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "ghdwdm"); m_InvInfo.m_fkdwsh = m_pXmlParse.GetText(); DBG_PRINT(("m_InvInfo.m_fkdwsh : %s",m_InvInfo.m_fkdwsh.c_str())); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "ghdwmc"); m_InvInfo.m_fkdw = m_pXmlParse.GetText(); DBG_PRINT(("m_InvInfo.m_fkdw : %s",m_InvInfo.m_fkdw.c_str())); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "sfxm"); m_pXmlParse.m_parentElement[5] = m_pXmlParse.m_Child; m_InvInfo.m_sphsl = atoi(m_pXmlParse.GetAttr("count").c_str()); DBG_PRINT(("m_InvInfo.m_sphsl : %u", m_InvInfo.m_sphsl)); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "skr"); m_InvInfo.m_sky = m_pXmlParse.GetText();//中间件工程中,skr、kpr、zfr全用m_sky组装 DBG_PRINT(("m_InvInfo.m_sky : %s", m_InvInfo.m_sky.c_str())); CInvDet *pInvDet = NULL; for (j=0; j<m_InvInfo.m_sphsl; j++) { pInvDet = pInvDet->GetNewInvDet(); //从静态数组获取一个可用的CInvDet对象 DBG_ASSERT_EXIT((pInvDet != NULL), (" pInvDet == NULL!")); pInvDet->m_fpdm = m_InvInfo.m_fpdm; pInvDet->m_fphm = m_InvInfo.m_fphm; pInvDet->m_kprq = m_InvInfo.m_kprq; pInvDet->m_kpsj = m_InvInfo.m_kpsj; pInvDet->m_kplx = m_InvInfo.m_kplx; pInvDet->m_sky = m_InvInfo.m_sky; pInvDet->m_sphxh = j+1; m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[5], "group", j); m_pXmlParse.m_parentElement[6] = m_pXmlParse.m_Child; m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[6], "xm");; pInvDet->m_spmc = m_pXmlParse.GetText(); DBG_PRINT(("pInvDet->m_spmc : %s", pInvDet->m_spmc.c_str())); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[6], "dj"); pInvDet->m_dj = atof(m_pXmlParse.GetText().c_str());//单价不含税 DBG_PRINT(("pInvDet->m_dj : %.3lf", pInvDet->m_dj)); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[6], "sl"); pInvDet->m_spsl = atof(m_pXmlParse.GetText().c_str());//数量 DBG_PRINT(("pInvDet->m_spdj : %.3lf", pInvDet->m_spsl)); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[6], "je"); pInvDet->m_je = double2int(atof(m_pXmlParse.GetText().c_str())*SUM_EXTENSION);//金额不含税 DBG_PRINT(("pInvDet->m_spje : %lld", pInvDet->m_je)); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[6], "zsl"); pInvDet->m_sl = atof(m_pXmlParse.GetText().c_str());//税率 DBG_PRINT(("pInvDet->m_sl : %.2lf", pInvDet->m_sl)); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[6], "se"); pInvDet->m_spse = double2int(atof(m_pXmlParse.GetText().c_str())*SUM_EXTENSION);//税额 DBG_PRINT(("pInvDet->m_spse : %lld", pInvDet->m_spse)); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[6], "hsdj"); pInvDet->m_spdj = atof(m_pXmlParse.GetText().c_str());//含税单价 DBG_PRINT(("pInvDet->m_spdj : %.3lf", pInvDet->m_spdj)); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[6], "hsje"); pInvDet->m_spje = double2int(atof(m_pXmlParse.GetText().c_str())*SUM_EXTENSION);//含税金额 DBG_PRINT(("pInvDet->m_spje : %lld", pInvDet->m_spje)); m_InvInfo.InsertNode(pInvDet); pInvDet =NULL; } m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "hjje"); m_InvInfo.m_kpje = double2int(atof(m_pXmlParse.GetText().c_str())*SUM_EXTENSION); DBG_PRINT(("m_InvInfo.m_kpje : %lld", m_InvInfo.m_kpje)); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "hjse"); m_InvInfo.m_kpse = double2int(atof(m_pXmlParse.GetText().c_str())*SUM_EXTENSION); DBG_PRINT(("m_InvInfo.m_kpse : %lld", m_InvInfo.m_kpse)); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "jshj"); m_InvInfo.m_kphjje = double2int(atof(m_pXmlParse.GetText().c_str())*SUM_EXTENSION); DBG_PRINT(("m_InvInfo.m_kphjje : %lld", m_InvInfo.m_kphjje)); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "bz"); m_InvInfo.m_backup1 = m_pXmlParse.GetText(); DBG_PRINT(("m_InvInfo.m_backup1 : %s", m_InvInfo.m_backup1.c_str())); // m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "kpr"); // m_InvInfo.m_sky = m_pXmlParse.GetText(); // DBG_PRINT(("m_InvInfo.m_sky : %s", m_InvInfo.m_sky.c_str())); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "yfpdm"); m_InvInfo.m_yfpdm = m_pXmlParse.GetText(); DBG_PRINT(("m_InvInfo.m_yfpdm : %s", m_InvInfo.m_yfpdm.c_str())); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "yfphm"); m_InvInfo.m_yfphm = atoi(m_pXmlParse.GetText().c_str()); //作废日期 // m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "zfrq"); // memset(Buf, 0, sizeof(Buf)); // sprintf(Buf, "%u",m_InvInfo.zfrq); // m_pXmlParse.GetText(Buf); // DBG_PRINT(("buf : %s", Buf)); //作废人 // m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "zfr"); // m_pXmlParse.GetText(m_InvInfo.m_yfpdm); // DBG_PRINT(("m_InvInfo.m_yfpdm : %s", m_InvInfo.m_yfpdm.c_str())); //已开负数金额 // m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[4], "ykfsje"); // memset(Buf, 0, sizeof(Buf)); // sprintf(Buf, "%ld", m_InvInfo.m_kphjje); // m_pXmlParse.GetText(Buf); // DBG_PRINT(("buf : %s", Buf)); m_pXmlParse.LocateNodeByName(m_pXmlParse.m_parentElement[2], "qmz"); m_InvInfo.m_casign = m_pXmlParse.GetText(); DBG_PRINT(("m_InvInfo.m_casign : %s", m_InvInfo.m_casign.c_str())); } return XML_SUCCESS; }