-
Notifications
You must be signed in to change notification settings - Fork 10
/
Voucher.cs
198 lines (168 loc) · 4.31 KB
/
Voucher.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
/* Copyright (C) 2020-2024 b1f6c1c4
*
* This file is part of ProfessionalAccounting.
*
* ProfessionalAccounting is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, version 3.
*
* ProfessionalAccounting is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
* for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with ProfessionalAccounting. If not, see
* <https://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Xml.Serialization;
namespace AccountingServer.Entities;
/// <summary>
/// 记账凭证类别
/// </summary>
[Serializable]
public enum VoucherType
{
/// <summary>
/// 普通记账凭证
/// </summary>
Ordinary,
/// <summary>
/// 非结转记账凭证
/// <remarks>仅检索时使用</remarks>
/// </summary>
General,
/// <summary>
/// 期末结转记账凭证
/// </summary>
Carry,
/// <summary>
/// 摊销记账凭证
/// </summary>
Amortization,
/// <summary>
/// 折旧记账凭证
/// </summary>
Depreciation,
/// <summary>
/// 减值记账凭证
/// </summary>
Devalue,
/// <summary>
/// 结转记账凭证
/// </summary>
AnnualCarry,
/// <summary>
/// 不准确记账凭证
/// </summary>
Uncertain,
}
/// <summary>
/// 记账凭证
/// </summary>
[Serializable]
public class Voucher
{
public Voucher() { }
public Voucher(Voucher v)
{
ID = v.ID;
Date = v.Date;
Remark = v.Remark;
Type = v.Type;
if (v.Details != null)
Details = v.Details.Select(static d => new VoucherDetail(d)).ToList();
}
/// <summary>
/// 编号
/// </summary>
[XmlAttribute("id")]
public string ID { get; set; }
/// <summary>
/// 日期,若为<c>null</c>表示无日期
/// </summary>
public DateTime? Date { get; set; }
/// <summary>
/// 备注
/// </summary>
[XmlAttribute("remark")]
public string Remark { get; set; }
/// <summary>
/// 细目
/// </summary>
[XmlElement("Detail")]
public List<VoucherDetail> Details { get; set; }
/// <summary>
/// 类别
/// </summary>
[DefaultValue(VoucherType.Ordinary)]
public VoucherType? Type { get; set; }
}
/// <summary>
/// 细目
/// </summary>
[Serializable]
public class VoucherDetail
{
/// <summary>
/// 判断金额相等的误差
/// </summary>
public const double Tolerance = 1e-8;
public VoucherDetail() { }
public VoucherDetail(VoucherDetail d)
{
User = d.User;
Currency = d.Currency;
Title = d.Title;
SubTitle = d.SubTitle;
Content = d.Content;
Fund = d.Fund;
Remark = d.Remark;
}
/// <summary>
/// 用户
/// </summary>
[XmlAttribute("user")]
public string User { get; set; }
/// <summary>
/// 币种
/// </summary>
[XmlAttribute("currency")]
public string Currency { get; set; }
/// <summary>
/// 会计科目一级科目代码
/// </summary>
public int? Title { get; set; }
/// <summary>
/// 会计科目二级科目代码,若为<c>null</c>表示无二级科目
/// </summary>
public int? SubTitle { get; set; }
/// <summary>
/// 内容
/// </summary>
public string Content { get; set; }
/// <summary>
/// 金额
/// </summary>
public double? Fund { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
/// <summary>
/// 带有指针的细目
/// </summary>
public class VoucherDetailR : VoucherDetail
{
public VoucherDetailR(Voucher v, VoucherDetail d) : base(d) => Voucher = v;
public VoucherDetailR(VoucherDetailR d) : this(new(d.Voucher), d) { }
/// <summary>
/// 所属记账凭证
/// </summary>
public Voucher Voucher { get; }
}