using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace HH.YiDaSyncNC.Models
{
public class HKD_GL_SyncServiceModel
{
#region 凭证数据模型
///
/// 凭证模型
///
public class DataModel
{
///
/// 头部
///
public class voucher_header
{
///
/// 会计年度
///
public string year { get; set; }
///
/// 会计期间
///
public string period { get; set; }
///
/// 凭证类别
///
public string pk_vouchertype { get; set; }
///
/// 制单日期
///
public string prepareddate { get; set; }
///
/// 凭证号
///
public string no { get; set; }
///
/// 账簿
///
public string pk_accountingbook { get; set; }
///
/// 制单人
///
public string pk_prepared { get; set; }
///
/// 附件张数
///
public string attachment { get; set; }
///
/// 组织
///
public string org { get; set; }
}
///
/// 头部分录
///
public class voucher_body
{
///
/// 分录序号
///
public int detailindex { get; set; }
///
/// 科目编码
///
public string accsubjcode { get; set; }
///
/// 摘要
///
public string explanation { get; set; }
public string verifydate { get; set; }
public string price { get; set; }
public string excrate2 { get; set; }
public string debitquantity { get; set; }
///
/// 借方金额
///
public string debitamount { get; set; }
public string groupdebitamount { get; set; }
public string globaldebitamount { get; set; }
///
/// 借方金额
///
public string localdebitamount { get; set; }
public string creditquantity { get; set; }
///
/// 贷方金额
///
public string creditamount { get; set; }
public string groupcreditamount { get; set; }
public string globalcreditamount { get; set; }
///
/// 贷方金额
///
public string localcreditamount { get; set; }
public string billtype { get; set; }
public string bankaccount { get; set; }
public string checkstyle { get; set; }
public string checkno { get; set; }
public string checkdate { get; set; }
public string bill_id { get; set; }
public string bill_date { get; set; }
public string pk_currtype { get; set; }
///
/// 科目编码
///
public string pk_accasoa { get; set; }
public string pk_unit { get; set; }
public string pk_unit_v { get; set; }
///
/// 辅助核算
///
public List ass { get; set; }
///
/// 现金流量
///
public DataModel.cash_flow cash_flow { get; set; }
}
public class cash_flow
{
public string m_pk_currtype { get; set; }
public string money { get; set; }
public string moneyglobal { get; set; }
public string moneygroup { get; set; }
public string moneymain { get; set; }
///
/// 现金主键
///
public string pk_cashflow { get; set; }
public string pk_innercorp { get; set; }
}
public class ass
{
///
/// 辅助核算类型 编码
///
public string pk_Checktype { get; set; }
///
/// 值
///
public string pk_Checkvalue { get; set; }
}
}
#endregion
public class ImportXml_凭证
{
public static XElement TemplateHeade(DataModel.voucher_header item)
{
return new XElement(new XElement("ufinterface", new object[]
{
new XAttribute("proc","add"),
new XAttribute("sender","dingding"),
new XAttribute("receiver",item.org),
new XAttribute("roottag",""),
new XAttribute("replace","N"),
new XAttribute("orgcode",item.org),
new XAttribute("isexchange",""),
new XAttribute("groupcode","0"),
new XAttribute("filename",""),
new XAttribute("businessunitcode","develop"),
new XAttribute("billtype","vouchergl"),
new XAttribute("account","develop")
}));
}
///
/// 组建表头xml
///
/// 表头参数
///
public static XElement Header(DataModel.voucher_header item)
{
return new XElement("voucher", new object[]
{
"",
//new XAttribute("id",""),
new XElement("voucher_head", new object[]
{
new XElement("pk_voucher",""),
new XElement("pk_vouchertype",item.pk_vouchertype),
new XElement("year",item.year),
new XElement("pk_system","GL"),
new XElement("voucherkind","0"),
new XElement("pk_accountingbook",item.pk_accountingbook),
new XElement("discardflag","N"),
new XElement("period",item.period),
new XElement("no",item.no),
new XElement("attachment",""),
new XElement("prepareddate",item.prepareddate),
new XElement("pk_prepared",/*"DINGDING"*/item.pk_prepared),
new XElement("pk_casher",""),
new XElement("signflag","Y"),
new XElement("pk_checked",""),
new XElement("tallydate",""),
new XElement("pk_manager",""),
new XElement("memo1",""),
new XElement("memo2",""),
new XElement("reserve1",""),
new XElement("reserve2","N"),
new XElement("siscardflag",""),
new XElement("pk_org",item.org),
new XElement("pk_org_v",item.org),
new XElement("pk_group","0"),
new XElement("details","")
}),
});
}
///
/// 组建表体xml
///
/// 表体
///
public static List Bodydebit(List items)
{
List list = new List();
foreach (DataModel.voucher_body current in items)
{
List lstItem = new List();
foreach (var ite in current.ass)
{
if (!string.IsNullOrWhiteSpace(ite.pk_Checktype) && !string.IsNullOrWhiteSpace(ite.pk_Checkvalue))
{
XElement ites = new XElement("item", new object[] {
new XElement("pk_Checktype",ite.pk_Checktype),
new XElement("pk_Checkvalue",ite.pk_Checkvalue)
});
lstItem.Add(ites);
}
}
XElement item = new XElement("item", new object[]
{
new XElement("detailindex",current.detailindex),
new XElement("accsubjcode",current.pk_accasoa),
new XElement("explanation",current.explanation),
new XElement("verifydate",current.verifydate),
new XElement("price",current.price),
new XElement("excrate2",current.excrate2),
new XElement("debitquantity",current.debitquantity),
new XElement("debitamount",current.debitamount),
new XElement("groupdebitamount",current.groupdebitamount),
new XElement("globaldebitamount",current.globaldebitamount),
new XElement("localdebitamount",current.localdebitamount),
new XElement("creditquantity",current.creditquantity),
new XElement("creditamount",current.creditamount),
new XElement("groupcreditamount",current.groupcreditamount),
new XElement("globalcreditamount",current.globalcreditamount),
new XElement("localcreditamount",current.localcreditamount),
new XElement("billtype",current.billtype),
new XElement("bankaccount",current.bankaccount),
new XElement("checkstyle",current.checkstyle),
new XElement("checkno",current.checkno),
new XElement("checkdate",current.checkdate),
new XElement("bill_id",current.bill_id),
new XElement("bill_date",current.bill_date),
new XElement("pk_currtype",current.pk_currtype),
new XElement("pk_accasoa",current.pk_accasoa),
new XElement("ass",new object[]
{
lstItem,
}),
});
if (!string.IsNullOrWhiteSpace(current.cash_flow.m_pk_currtype) && !string.IsNullOrWhiteSpace(current.cash_flow.money) && !string.IsNullOrWhiteSpace(current.cash_flow.moneymain) && !string.IsNullOrWhiteSpace(current.cash_flow.pk_cashflow))
{
XElement cashFlow = new XElement("cashFlow", new XElement("item", new object[]
{
new XElement("m_pk_currtype",current.cash_flow.m_pk_currtype),
new XElement("money",current.cash_flow.money),
new XElement("moneyglobal",current.cash_flow.moneyglobal),
new XElement("moneygroup",current.cash_flow.moneygroup),
new XElement("moneymain",current.cash_flow.moneymain),
new XElement("pk_cashflow",current.cash_flow.pk_cashflow),
new XElement("pk_innercorp",current.cash_flow.pk_innercorp)
}));
item.Add(cashFlow);
}
list.Add(item);
}
return list;
}
}
}
}