FKGL_SyncServiceModel.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Xml.Linq;
  7. namespace HH.YiDaSyncNC.Models
  8. {
  9. public class FKGL_SyncServiceModel
  10. {
  11. #region 凭证数据模型
  12. /// <summary>
  13. /// 凭证模型
  14. /// </summary>
  15. public class DataModel
  16. {
  17. /// <summary>
  18. /// 头部
  19. /// </summary>
  20. public class voucher_header
  21. {
  22. /// <summary>
  23. /// 会计年度
  24. /// </summary>
  25. public string year { get; set; }
  26. /// <summary>
  27. /// 会计期间
  28. /// </summary>
  29. public string period { get; set; }
  30. /// <summary>
  31. /// 凭证类别
  32. /// </summary>
  33. public string pk_vouchertype { get; set; }
  34. /// <summary>
  35. /// 制单日期
  36. /// </summary>
  37. public string prepareddate { get; set; }
  38. /// <summary>
  39. /// 凭证号
  40. /// </summary>
  41. public string no { get; set; }
  42. /// <summary>
  43. /// 账簿
  44. /// </summary>
  45. public string pk_accountingbook { get; set; }
  46. /// <summary>
  47. /// 制单人
  48. /// </summary>
  49. public string pk_prepared { get; set; }
  50. /// <summary>
  51. /// 附件张数
  52. /// </summary>
  53. public string attachment { get; set; }
  54. /// <summary>
  55. /// 组织
  56. /// </summary>
  57. public string org { get; set; }
  58. }
  59. /// <summary>
  60. /// 头部分录
  61. /// </summary>
  62. public class voucher_body
  63. {
  64. /// <summary>
  65. /// 分录序号
  66. /// </summary>
  67. public int detailindex { get; set; }
  68. /// <summary>
  69. /// 科目编码
  70. /// </summary>
  71. public string accsubjcode { get; set; }
  72. /// <summary>
  73. /// 摘要
  74. /// </summary>
  75. public string explanation { get; set; }
  76. public string verifydate { get; set; }
  77. public string price { get; set; }
  78. public string excrate2 { get; set; }
  79. public string debitquantity { get; set; }
  80. /// <summary>
  81. /// 借方金额
  82. /// </summary>
  83. public string debitamount { get; set; }
  84. public string groupdebitamount { get; set; }
  85. public string globaldebitamount { get; set; }
  86. /// <summary>
  87. /// 借方金额
  88. /// </summary>
  89. public string localdebitamount { get; set; }
  90. public string creditquantity { get; set; }
  91. /// <summary>
  92. /// 贷方金额
  93. /// </summary>
  94. public string creditamount { get; set; }
  95. public string groupcreditamount { get; set; }
  96. public string globalcreditamount { get; set; }
  97. /// <summary>
  98. /// 贷方金额
  99. /// </summary>
  100. public string localcreditamount { get; set; }
  101. public string billtype { get; set; }
  102. public string bankaccount { get; set; }
  103. public string checkstyle { get; set; }
  104. public string checkno { get; set; }
  105. public string checkdate { get; set; }
  106. public string bill_id { get; set; }
  107. public string bill_date { get; set; }
  108. public string pk_currtype { get; set; }
  109. /// <summary>
  110. /// 科目编码
  111. /// </summary>
  112. public string pk_accasoa { get; set; }
  113. public string pk_unit { get; set; }
  114. public string pk_unit_v { get; set; }
  115. /// <summary>
  116. /// 辅助核算
  117. /// </summary>
  118. public List<DataModel.ass> ass { get; set; }
  119. /// <summary>
  120. /// 现金流量
  121. /// </summary>
  122. public DataModel.cash_flow cash_flow { get; set; }
  123. }
  124. public class cash_flow
  125. {
  126. public string m_pk_currtype { get; set; }
  127. public string money { get; set; }
  128. public string moneyglobal { get; set; }
  129. public string moneygroup { get; set; }
  130. public string moneymain { get; set; }
  131. /// <summary>
  132. /// 现金主键
  133. /// </summary>
  134. public string pk_cashflow { get; set; }
  135. public string pk_innercorp { get; set; }
  136. }
  137. public class ass
  138. {
  139. /// <summary>
  140. /// 辅助核算类型 编码
  141. /// </summary>
  142. public string pk_Checktype { get; set; }
  143. /// <summary>
  144. /// 值
  145. /// </summary>
  146. public string pk_Checkvalue { get; set; }
  147. }
  148. }
  149. #endregion
  150. public class ImportXml_凭证
  151. {
  152. public static XElement TemplateHeade(DataModel.voucher_header item)
  153. {
  154. return new XElement(new XElement("ufinterface", new object[]
  155. {
  156. new XAttribute("proc","add"),
  157. new XAttribute("sender","dingding"),
  158. new XAttribute("receiver",item.org),
  159. new XAttribute("roottag",""),
  160. new XAttribute("replace","N"),
  161. new XAttribute("orgcode",item.org),
  162. new XAttribute("isexchange",""),
  163. new XAttribute("groupcode","0"),
  164. new XAttribute("filename",""),
  165. new XAttribute("businessunitcode","develop"),
  166. new XAttribute("billtype","vouchergl"),
  167. new XAttribute("account","develop")
  168. }));
  169. }
  170. /// <summary>
  171. /// 组建表头xml
  172. /// </summary>
  173. /// <param name="item">表头参数</param>
  174. /// <returns></returns>
  175. public static XElement Header(DataModel.voucher_header item)
  176. {
  177. return new XElement("voucher", new object[]
  178. {
  179. "",
  180. //new XAttribute("id",""),
  181. new XElement("voucher_head", new object[]
  182. {
  183. new XElement("pk_voucher",""),
  184. new XElement("pk_vouchertype",item.pk_vouchertype),
  185. new XElement("year",item.year),
  186. new XElement("pk_system","GL"),
  187. new XElement("voucherkind","0"),
  188. new XElement("pk_accountingbook",item.pk_accountingbook),
  189. new XElement("discardflag","N"),
  190. new XElement("period",item.period),
  191. new XElement("no",item.no),
  192. new XElement("attachment",""),
  193. new XElement("prepareddate",item.prepareddate),
  194. new XElement("pk_prepared",/*"DINGDING"*/item.pk_prepared),
  195. new XElement("pk_casher",""),
  196. new XElement("signflag","Y"),
  197. new XElement("pk_checked",""),
  198. new XElement("tallydate",""),
  199. new XElement("pk_manager",""),
  200. new XElement("memo1",""),
  201. new XElement("memo2",""),
  202. new XElement("reserve1",""),
  203. new XElement("reserve2","N"),
  204. new XElement("siscardflag",""),
  205. new XElement("pk_org",item.org),
  206. new XElement("pk_org_v",item.org),
  207. new XElement("pk_group","0"),
  208. new XElement("details","")
  209. }),
  210. });
  211. }
  212. /// <summary>
  213. /// 组建表体xml
  214. /// </summary>
  215. /// <param name="items">表体</param>
  216. /// <returns></returns>
  217. public static List<XElement> Bodydebit(List<DataModel.voucher_body> items)
  218. {
  219. List<XElement> list = new List<XElement>();
  220. foreach (DataModel.voucher_body current in items)
  221. {
  222. List<XElement> lstItem = new List<XElement>();
  223. foreach (var ite in current.ass)
  224. {
  225. if (!string.IsNullOrWhiteSpace(ite.pk_Checktype) && !string.IsNullOrWhiteSpace(ite.pk_Checkvalue))
  226. {
  227. XElement ites = new XElement("item", new object[] {
  228. new XElement("pk_Checktype",ite.pk_Checktype),
  229. new XElement("pk_Checkvalue",ite.pk_Checkvalue)
  230. });
  231. lstItem.Add(ites);
  232. }
  233. }
  234. XElement item = new XElement("item", new object[]
  235. {
  236. new XElement("detailindex",current.detailindex),
  237. new XElement("accsubjcode",current.pk_accasoa),
  238. new XElement("explanation",current.explanation),
  239. new XElement("verifydate",current.verifydate),
  240. new XElement("price",current.price),
  241. new XElement("excrate2",current.excrate2),
  242. new XElement("debitquantity",current.debitquantity),
  243. new XElement("debitamount",current.debitamount),
  244. new XElement("groupdebitamount",current.groupdebitamount),
  245. new XElement("globaldebitamount",current.globaldebitamount),
  246. new XElement("localdebitamount",current.localdebitamount),
  247. new XElement("creditquantity",current.creditquantity),
  248. new XElement("creditamount",current.creditamount),
  249. new XElement("groupcreditamount",current.groupcreditamount),
  250. new XElement("globalcreditamount",current.globalcreditamount),
  251. new XElement("localcreditamount",current.localcreditamount),
  252. new XElement("billtype",current.billtype),
  253. new XElement("bankaccount",current.bankaccount),
  254. new XElement("checkstyle",current.checkstyle),
  255. new XElement("checkno",current.checkno),
  256. new XElement("checkdate",current.checkdate),
  257. new XElement("bill_id",current.bill_id),
  258. new XElement("bill_date",current.bill_date),
  259. new XElement("pk_currtype",current.pk_currtype),
  260. new XElement("pk_accasoa",current.pk_accasoa),
  261. new XElement("ass",new object[]
  262. {
  263. lstItem,
  264. }),
  265. });
  266. 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))
  267. {
  268. XElement cashFlow = new XElement("cashFlow", new XElement("item", new object[]
  269. {
  270. new XElement("m_pk_currtype",current.cash_flow.m_pk_currtype),
  271. new XElement("money",current.cash_flow.money),
  272. new XElement("moneyglobal",current.cash_flow.moneyglobal),
  273. new XElement("moneygroup",current.cash_flow.moneygroup),
  274. new XElement("moneymain",current.cash_flow.moneymain),
  275. new XElement("pk_cashflow",current.cash_flow.pk_cashflow),
  276. new XElement("pk_innercorp",current.cash_flow.pk_innercorp)
  277. }));
  278. item.Add(cashFlow);
  279. }
  280. list.Add(item);
  281. }
  282. return list;
  283. }
  284. }
  285. }
  286. }