229{
230 try
231 {
232
233 m_errors.erase(prop_type);
234
235 switch (prop_type)
236 {
237 case GncTransPropType::UNIQUE_ID:
238 m_differ.reset();
239 if (!value.empty())
240 m_differ = value;
241 break;
242
243 case GncTransPropType::DATE:
244 m_date.reset();
245 if (!value.empty())
247 else if (!m_multi_split)
248 throw std::invalid_argument (
249 (bl::format (std::string{
_(
"Date field can not be empty if 'Multi-split' option is unset.\n")}) %
250 std::string{
_(gnc_csv_col_type_strs[prop_type])}).str());
251 break;
252
253 case GncTransPropType::NUM:
254 m_num.reset();
255 if (!value.empty())
256 m_num = value;
257 break;
258
259 case GncTransPropType::DESCRIPTION:
260 m_desc.reset();
261 if (!value.empty())
262 m_desc = value;
263 else if (!m_multi_split)
264 throw std::invalid_argument (
265 (bl::format (std::string{
_(
"Description field can not be empty if 'Multi-split' option is unset.\n")}) %
266 std::string{
_(gnc_csv_col_type_strs[prop_type])}).str());
267 break;
268
269 case GncTransPropType::NOTES:
270 m_notes.reset();
271 if (!value.empty())
272 m_notes = value;
273 break;
274
275 case GncTransPropType::COMMODITY:
276 m_currency = nullptr;
277 m_currency = parse_commodity (value);
278 break;
279
280 case GncTransPropType::VOID_REASON:
281 m_void_reason.reset();
282 if (!value.empty())
283 m_void_reason = value;
284 break;
285
286 default:
287
288 PWARN (
"%d is an invalid property for a transaction",
static_cast<int>(prop_type));
289 break;
290 }
291 }
292 catch (const std::exception& e)
293 {
294 auto err_str = (bl::format (std::string{
_(
"{1}: {2}")}) %
295 std::string{
_(gnc_csv_col_type_strs[prop_type])} %
296 e.what()).str();
297 m_errors.emplace(prop_type, err_str);
298 }
299
300}
static const std::vector< GncDateFormat > c_formats
A vector with all the date formats supported by the string constructor.