/// <summary> /// check before save /// </summary> /// <exception cref="MandatoryFieldIsMissing"></exception> public void CheckBeforeSave() { if (_recAcc == null) { throw new MandatoryFieldIsMissing(REC_ACC); } if (_glAccount == null) { throw new MandatoryFieldIsMissing(GL_ACCOUNT); } if (_vendor == null) { throw new MandatoryFieldIsMissing(VENDOR); } if (_date == null) { throw new MandatoryFieldIsMissing(EntryTemplate.POSTING_DATE); } if (_amount.IsZero() || _amount.IsNegative()) { throw new MandatoryFieldIsMissing(EntryTemplate.AMOUNT); } if (_businessArea == null) { throw new MandatoryFieldIsMissing(BUSINESS_AREA); } }
/// <summary> /// check before saving /// </summary> /// <exception cref="MandatoryFieldIsMissing"></exception> public void CheckBeforeSave() { if (_recAcc == null) { throw new MandatoryFieldIsMissing(REC_ACC); } if (_glAccount == null) { throw new MandatoryFieldIsMissing(GL_ACCOUNT); } if (_customer == null) { throw new MandatoryFieldIsMissing(CUSTOMER); } if (_date == null) { throw new MandatoryFieldIsMissing(EntryTemplate.POSTING_DATE); } if (_amount.IsZero() || _amount.IsNegative()) { throw new MandatoryFieldIsMissing(EntryTemplate.AMOUNT); } }
/// <summary> /// check wether mandatory fields is empty /// </summary> /// <exception cref="MandatoryFieldIsMissing"></exception> public void CheckMandatory() { // check account if (_type == AccountType.GL_ACCOUNT) { if (!(_glAccount != null && _customer == null && _vendor == null)) { _coreDriver .logDebugInfo( this.GetType(), 319, "Check line item before save, account error when account type is G/L account.", MessageType.ERRO); throw new MandatoryFieldIsMissing("G/L Account"); } } else if (_type == AccountType.CUSTOMER) { if (!(_glAccount != null && _customer != null && _vendor == null)) { _coreDriver .logDebugInfo( this.GetType(), 319, "Check line item before save, account error when account type is customer.", MessageType.ERRO); throw new MandatoryFieldIsMissing("Customer"); } } else { if (!(_glAccount != null && _customer == null && _vendor != null)) { _coreDriver .logDebugInfo( this.GetType(), 319, "Check line item before save, account error when account type is vendor.", MessageType.ERRO); throw new MandatoryFieldIsMissing("Vendor"); } } if (_amount.IsZero() || _amount.IsNegative()) { _coreDriver.logDebugInfo(this.GetType(), 319, "Check line item before save, amount <= 0.", MessageType.ERRO); throw new MandatoryFieldIsMissing("Amount"); } _coreDriver.logDebugInfo(this.GetType(), 319, String.Format( "Check line item %d before save successfully", _lineNum), MessageType.INFO); }
/// <summary> /// name of field, cannot set default value on date /// </summary> /// <param name="name"></param> /// <param name="value"></param> /// <exception cref="NotInValueRangeException">The value enter in is not in supported value range</exception> /// <exception cref="NoFieldNameException">No such field name</exception> public void AddDefaultValue(String name, Object value) { if (value == null) { return; } if (name.Equals(AMOUNT)) { CurrencyAmount amount = value as CurrencyAmount; if (value != null) { if (amount.IsNegative()) { throw new NotInValueRangeException(name, value); } _defaultValues.Add(name, value); return; } throw new NotInValueRangeException(name, value); } else if (name.Equals(TEXT)) { if (value is String) { _defaultValues.Add(name, value); return; } throw new NotInValueRangeException(name, value); } switch (_entryType) { case EntryType.GLEntry: checkValueGLEntry(name, value); _defaultValues.Add(name, value); break; case EntryType.VendorEntry: checkValueVendorEntry(name, value); _defaultValues.Add(name, value); break; case EntryType.CustomerEntry: checkValueCustomerEntry(name, value); _defaultValues.Add(name, value); break; } }
/// <summary> /// Set amount /// </summary> /// <param name="indicator"></param> /// <param name="amount"></param> /// <returns></returns> public bool SetAmount(CreditDebitIndicator indicator, CurrencyAmount amount) { if (_isSaved) { return(false); } if (amount == null) { return(false); } if (amount.IsNegative()) { return(false); } _cdIndicator = indicator; _amount.Set(amount); return(true); }
/// <summary> /// Check the document entry before saving /// </summary> /// <exception cref="MandatoryFieldIsMissing"></exception> public void CheckBeforeSave() { if (_srcAccount == null) { throw new MandatoryFieldIsMissing(SRC_ACCOUNT); } if (_dstAccount == null) { throw new MandatoryFieldIsMissing(DST_ACCOUNT); } if (_amount.IsNegative() || _amount.IsZero()) { throw new MandatoryFieldIsMissing(EntryTemplate.AMOUNT); } if (_pstDate == null) { throw new MandatoryFieldIsMissing(EntryTemplate.POSTING_DATE); } }
/// <summary> /// Set value /// </summary> /// <param name="fieldName"></param> /// <param name="value"></param> /// <exception cref="NoFieldNameException"></exception> /// <exception cref="NotInValueRangeException"></exception> public void SetValue(String fieldName, Object value) { if (_isSaved) { return; } if (value == null) { throw new NotInValueRangeException(fieldName, ""); } if (fieldName.Equals(CUSTOMER)) { MasterDataIdentity customer = value as MasterDataIdentity; if (customer == null) { throw new NotInValueRangeException(fieldName, value); } setCustomer(customer); } else if (fieldName.Equals(GL_ACCOUNT)) { MasterDataIdentity_GLAccount glAccount = value as MasterDataIdentity_GLAccount; if (glAccount == null) { throw new NotInValueRangeException(fieldName, value); } setGLAccount(glAccount); } else if (fieldName.Equals(REC_ACC)) { MasterDataIdentity_GLAccount recAcc = value as MasterDataIdentity_GLAccount; if (recAcc == null) { throw new NotInValueRangeException(fieldName, value); } setRecAccount(recAcc); } else if (fieldName.Equals(EntryTemplate.POSTING_DATE)) { if (!(value is DateTime)) { throw new NotInValueRangeException(fieldName, value); } DateTime date = (DateTime)value; _date = date; } else if (fieldName.Equals(EntryTemplate.AMOUNT)) { try { CurrencyAmount amount = CurrencyAmount.Parse(value.ToString()); if (amount.IsZero() || amount.IsNegative()) { throw new NotInValueRangeException(fieldName, value); } _amount = amount; } catch (CurrencyAmountFormatException) { throw new NotInValueRangeException(fieldName, value); } } else if (fieldName.Equals(EntryTemplate.TEXT)) { _text = value.ToString(); } else { throw new NoFieldNameException(fieldName); } }
/// <summary> /// set value /// </summary> /// <param name="fieldName"></param> /// <param name="value"></param> /// <exception cref="NoFieldNameException">No such field name</exception> /// <exception cref="NotInValueRangeException">The value is not supported</exception> public void SetValue(String fieldName, Object value) { if (_isSaved) { return; } if (value == null) { throw new NotInValueRangeException(fieldName, ""); } if (fieldName.Equals(DST_ACCOUNT)) { if (!(value is MasterDataIdentity_GLAccount)) { throw new NotInValueRangeException(fieldName, value); } MasterDataIdentity_GLAccount id = (MasterDataIdentity_GLAccount)value; setDstAccount(id); } else if (fieldName.Equals(SRC_ACCOUNT)) { if (!(value is MasterDataIdentity_GLAccount)) { throw new NotInValueRangeException(fieldName, value); } MasterDataIdentity_GLAccount id = (MasterDataIdentity_GLAccount)value; setSourceAccount(id); } else if (fieldName.Equals(EntryTemplate.TEXT)) { _text = value.ToString(); } else if (fieldName.Equals(EntryTemplate.AMOUNT)) { try { CurrencyAmount amount = CurrencyAmount.Parse(value.ToString()); if (amount.IsZero() || amount.IsNegative()) { throw new NotInValueRangeException(fieldName, value); } _amount = amount; } catch (CurrencyAmountFormatException) { throw new NotInValueRangeException(fieldName, value); } } else if (fieldName.Equals(EntryTemplate.POSTING_DATE)) { if (!(value is DateTime)) { throw new NotInValueRangeException(fieldName, value); } DateTime pstDate = (DateTime)value; _pstDate = pstDate; } else { throw new NoFieldNameException(fieldName); } }
/// <summary> /// set value /// </summary> /// <param name="fieldName"></param> /// <param name="value"></param> /// <exception cref="NoFieldNameException">No such field name</exception> /// <exception cref="NotInValueRangeException">The value is not supported</exception> public void SetValue(String fieldName, Object value) { if (_isSaved) { return; } if (value == null) { throw new NotInValueRangeException(fieldName, ""); } if (fieldName.Equals(VENDOR)) { if (!(value is MasterDataIdentity)) { throw new NotInValueRangeException(fieldName, value); } MasterDataIdentity vendor = (MasterDataIdentity)value; setVendor(vendor); } else if (fieldName.Equals(GL_ACCOUNT)) { if (!(value is MasterDataIdentity_GLAccount)) { throw new NotInValueRangeException(fieldName, value); } MasterDataIdentity_GLAccount glAccount = (MasterDataIdentity_GLAccount)value; setGLAccount(glAccount); } else if (fieldName.Equals(REC_ACC)) { if (!(value is MasterDataIdentity_GLAccount)) { throw new NotInValueRangeException(fieldName, value); } MasterDataIdentity_GLAccount recAcc = (MasterDataIdentity_GLAccount)value; setRecAccount(recAcc); } else if (fieldName.Equals(EntryTemplate.POSTING_DATE)) { if (!(value is DateTime)) { throw new NotInValueRangeException(fieldName, value); } DateTime date = (DateTime)value; _date = date; } else if (fieldName.Equals(EntryTemplate.AMOUNT)) { try { CurrencyAmount amount = CurrencyAmount.Parse(value.ToString()); if (amount.IsZero() || amount.IsNegative()) { throw new NotInValueRangeException(fieldName, value); } _amount = amount; } catch (CurrencyAmountFormatException) { throw new NotInValueRangeException(fieldName, value); } } else if (fieldName.Equals(EntryTemplate.TEXT)) { _text = value.ToString(); } else if (fieldName.Equals(BUSINESS_AREA)) { if (!(value is MasterDataIdentity)) { throw new NotInValueRangeException(fieldName, value); } MasterDataIdentity businessArea = (MasterDataIdentity)value; setBusinessArea(businessArea); } else { throw new NoFieldNameException(fieldName); } }