public DollarCents(MonetaryAmount amt)
        {
            var dc = FromCents((int)Math.Round(amt.Microdollars / (decimal)MicrodollarsPerCent, MidpointRounding.ToEven));

            IsNegative = dc.IsNegative;
            Dollars    = dc.Dollars;
            Cents      = dc.Cents;
        }
        public void Two_amounts_can_be_compared()
        {
            var one = new MonetaryAmount(10M);
            var two = new MonetaryAmount(11M);

            Assert.True(one < two);
            Assert.False(one > two);
        }
        public void The_same_amounts_are_equal()
        {
            var one = new MonetaryAmount(10M);
            var two = new MonetaryAmount(10M);

            Assert.Equal(one, two);
            Assert.True(one == two);
        }
        public void Not_the_same_amounts_are_not_equal()
        {
            var one = new MonetaryAmount(10M);
            var two = new MonetaryAmount(11M);

            Assert.NotEqual(one, two);
            Assert.True(one != two);
        }
Beispiel #5
0
        public void Can_add()
        {
            var one = new MonetaryAmount(10M);
            var two = new MonetaryAmount(11M);

            var sum = one + two;

            Assert.Equal(sum, new MonetaryAmount(21M));
        }
Beispiel #6
0
        public void Can_subtract()
        {
            var one = new MonetaryAmount(10M);
            var two = new MonetaryAmount(5M);

            var diff = one - two;

            Assert.Equal(diff, new MonetaryAmount(5M));
        }
Beispiel #7
0
        public void Can_multiply_by_percent()
        {
            var one        = new MonetaryAmount(10M);
            var tenPercent = 10.Percent();

            var percentOfOne = one * tenPercent;

            Assert.Equal(percentOfOne, new MonetaryAmount(1M));
        }
 public TotalCommitments(
     Guid id,
     Facility facility,
     MonetaryAmount totalCommitments
     ) : base(
         id,
         facility)
 {
     Value = totalCommitments;
 }
Beispiel #9
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.CurrentCulture;
            string separator = IsSubcomponent ? Configuration.SubcomponentSeparator : Configuration.ComponentSeparator;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 2, separator),
                       MonetaryAmount?.ToDelimitedString(),
                       ChargeCode?.ToDelimitedString()
                       ).TrimEnd(separator.ToCharArray()));
        }
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.CurrentCulture;
            string separator = IsSubcomponent ? Configuration.SubcomponentSeparator : Configuration.ComponentSeparator;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 3, separator),
                       DelayDays.HasValue ? DelayDays.Value.ToString(Consts.NumericFormat, culture) : null,
                       MonetaryAmount?.ToDelimitedString(),
                       NumberOfDays.HasValue ? NumberOfDays.Value.ToString(Consts.NumericFormat, culture) : null
                       ).TrimEnd(separator.ToCharArray()));
        }
Beispiel #11
0
 /// <summary> Full constructor.</summary>
 public Item(string name, string description, User seller, MonetaryAmount initialPrice,
     MonetaryAmount reservePrice, DateTime startDate, DateTime endDate, ISet categories, IList bids,
     Bid successfulBid)
 {
     this.name = name;
     this.seller = seller;
     this.description = description;
     this.initialPrice = initialPrice;
     this.reservePrice = reservePrice;
     this.startDate = startDate;
     this.endDate = endDate;
     categorizedItems = categories;
     this.bids = bids;
     this.successfulBid = successfulBid;
     state = ItemState.Draft;
 }
        public MonetaryAmount GetMonetaryAmount(String key)
        {
            if (String.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException(nameof(key));
            }

            MonetaryAmount result = null;

            if (data.ContainsKey(key) && data[key] is MonetaryAmount)
            {
                result = ((ICloneable)data[key]).Clone() as MonetaryAmount;
            }

            return(result);
        }
Beispiel #13
0
        /// <inheritdoc/>
        public string ToDelimitedString()
        {
            CultureInfo culture = CultureInfo.CurrentCulture;

            return(string.Format(
                       culture,
                       StringHelper.StringFormatSequence(0, 34, Configuration.FieldSeparator),
                       Id,
                       DiagnosticRelatedGroup?.ToDelimitedString(),
                       DrgAssignedDateTime.HasValue ? DrgAssignedDateTime.Value.ToString(Consts.DateTimeFormatPrecisionSecond, culture) : null,
                       DrgApprovalIndicator,
                       DrgGrouperReviewCode?.ToDelimitedString(),
                       OutlierType?.ToDelimitedString(),
                       OutlierDays.HasValue ? OutlierDays.Value.ToString(Consts.NumericFormat, culture) : null,
                       OutlierCost?.ToDelimitedString(),
                       DrgPayor?.ToDelimitedString(),
                       OutlierReimbursement?.ToDelimitedString(),
                       ConfidentialIndicator,
                       DrgTransferType?.ToDelimitedString(),
                       NameOfCoder?.ToDelimitedString(),
                       GrouperStatus?.ToDelimitedString(),
                       PcclValueCode?.ToDelimitedString(),
                       EffectiveWeight.HasValue ? EffectiveWeight.Value.ToString(Consts.NumericFormat, culture) : null,
                       MonetaryAmount?.ToDelimitedString(),
                       StatusPatient?.ToDelimitedString(),
                       GrouperSoftwareName,
                       GrouperSoftwareVersion,
                       StatusFinancialCalculation?.ToDelimitedString(),
                       RelativeDiscountSurcharge?.ToDelimitedString(),
                       BasicCharge?.ToDelimitedString(),
                       TotalCharge?.ToDelimitedString(),
                       DiscountSurcharge?.ToDelimitedString(),
                       CalculatedDays.HasValue ? CalculatedDays.Value.ToString(Consts.NumericFormat, culture) : null,
                       StatusGender?.ToDelimitedString(),
                       StatusAge?.ToDelimitedString(),
                       StatusLengthOfStay?.ToDelimitedString(),
                       StatusSameDayFlag?.ToDelimitedString(),
                       StatusSeparationMode?.ToDelimitedString(),
                       StatusWeightAtBirth?.ToDelimitedString(),
                       StatusRespirationMinutes?.ToDelimitedString(),
                       StatusAdmission?.ToDelimitedString()
                       ).TrimEnd(Configuration.FieldSeparator.ToCharArray()));
        }
Beispiel #14
0
 public Facility(
     Guid id,
     Contract facilityAgreement,
     string name,
     MonetaryAmount totalCommitments,
     Expression <DateTime?> availabilityPeriodEndDate,
     Expression <DateTime?> maturityDate,
     bool multiCurrency,
     bool committed
     ) : base(
         id,
         facilityAgreement)
 {
     Name                      = name;
     Currency                  = totalCommitments.Currency;
     TotalCommitments          = new Variable <decimal?>(totalCommitments.Amount);
     AvailabilityPeriodEndDate = availabilityPeriodEndDate;
     MaturityDate              = maturityDate;
     MultiCurrency             = multiCurrency;
     Committed                 = committed;
 }
Beispiel #15
0
 ///<summary>Adds the value of the <c>&lt;AnnualItem&gt;</c> element.</summary>
 /// <param name="AccountType">Classification of budgetary account code summary</param>
 /// <param name="FundType">Is the account a general or special account code designation?</param>
 /// <param name="Function">Function break in account code for summarization.</param>
 /// <param name="Amount">Summarized amount.</param>
 ///<remarks>
 /// <para>This form of <c>setAnnualItem</c> is provided as a convenience method
 /// that is functionally equivalent to the method <c>AddAnnualItem</c></para>
 /// <para>Version: 2.6</para>
 /// <para>Since: 1.5r1</para>
 /// </remarks>
 public void AddAnnualItem(AccountClass AccountType, FundType FundType, string Function, MonetaryAmount Amount)
 {
     AddChild(HrfinDTD.ANNUALITEMS_ANNUALITEM, new AnnualItem(AccountType, FundType, Function, Amount));
 }
Beispiel #16
0
 /// <summary> Simple properties only constructor.</summary>
 public Item(string name, string description, User seller, MonetaryAmount initialPrice,
     MonetaryAmount reservePrice, DateTime startDate, DateTime endDate)
 {
     this.name = name;
     this.seller = seller;
     this.description = description;
     this.initialPrice = initialPrice;
     this.reservePrice = reservePrice;
     this.startDate = startDate;
     this.endDate = endDate;
     state = ItemState.Draft;
 }
Beispiel #17
0
        public virtual void Can_Place_Bid_For_Item()
        {
            InitData();

            ItemDAO itemDAO = new ItemDAO();
            UserDAO userDAO = new UserDAO();

            long tempAux = auctionTwo.Id;
            Bid currentMaxBid = itemDAO.GetMaxBid(tempAux);
            long tempAux2 = auctionTwo.Id;
            Bid currentMinBid = itemDAO.GetMinBid(tempAux2);
            long tempAux3 = auctionTwo.Id;
            Item a2 = itemDAO.GetById(tempAux3, true);

            // Fail, auction is not active yet
            try
            {
                double bidAmount = 99.99;
                MonetaryAmount newAmount = new MonetaryAmount(bidAmount, "USD");
                long tempAux4 = u3.Id;
                a2.PlaceBid(userDAO.GetById(tempAux4), newAmount, currentMaxBid, currentMinBid);
            }
            catch(BusinessException success)
            {
            }

            // Fail, user isn't an admin
            try
            {
                a2.Approve(u3);
            }
            catch(PermissionException success)
            {
            }

            // Success, set active
            a2.SetPendingForApproval();
            a2.Approve(u1);

            // Success, place a bid
            try
            {
                double bidAmount = 100.00;
                MonetaryAmount newAmount = new MonetaryAmount(bidAmount, "USD");
                long tempAux5 = u3.Id;
                a2.PlaceBid(userDAO.GetById(tempAux5), newAmount, currentMaxBid, currentMinBid);
            }
            catch(BusinessException failure)
            {
                throw failure;
            }

            // Fail, bid amount is too low
            try
            {
                double bidAmount = 99.99;
                MonetaryAmount newAmount = new MonetaryAmount(bidAmount, "USD");
                long tempAux6 = u3.Id;
                a2.PlaceBid(userDAO.GetById(tempAux6), newAmount, currentMaxBid, currentMinBid);
            }
            catch(BusinessException success)
            {
            }

            NHibernateHelper.CommitTransaction();
            NHibernateHelper.CloseSession();
        }
Beispiel #18
0
 public DecimalDollars(MonetaryAmount amt)
 {
     Amount = amt.Microdollars / (decimal)OneMillion;
 }
Beispiel #19
0
        /// <summary> Places a bid while checking business constraints.
        /// This method may throw a BusinessException if one of the requirements
        /// for the bid placement wasn't met, e.g. if the auction already ended.
        /// </summary>
        /// <param name="bidder">
        /// </param>
        /// <param name="bidAmount">
        /// </param>
        /// <param name="currentMaxBid"> the most valuable bid for this item
        /// </param>
        /// <param name="currentMinBid"> the least valuable bid for this item
        /// </param>
        /// <returns>
        /// </returns>
        public virtual Bid PlaceBid(User bidder, MonetaryAmount bidAmount, Bid currentMaxBid, Bid currentMinBid)
        {
            // Check highest bid (can also be a different Strategy (pattern))
            if (currentMaxBid != null && currentMaxBid.Amount.CompareTo(bidAmount) > 0)
            {
                throw new BusinessException("Bid too low.");
            }

            // Auction is active
            if (state != ItemState.Active)
                throw new BusinessException("Auction is not active yet.");

            // Auction still valid
            if (EndDate < DateTime.Now)
                throw new BusinessException("Can't place new bid, auction already ended.");

            // Create new Bid
            var newBid = new Bid(bidAmount, this, bidder);

            // Place bid for this Item
            AddBid(newBid);

            return newBid;
        }
 /// <summary>
 /// MonetaryAmountOrPriceSpecification as a MonetaryAmount.
 /// </summary>
 /// <param name="monetaryAmount">MonetaryAmountOrPriceSpecification as a MonetaryAmount.</param>
 public MonetaryAmountOrPriceSpecification(MonetaryAmount monetaryAmount)
 {
     AsMonetaryAmount = monetaryAmount;
 }
 ///<summary>Adds the value of the <c>&lt;SaleQuantity&gt;</c> element.</summary>
 /// <param name="Value">The value of sale quantity</param>
 /// <param name="MealStatus">A MealStatus</param>
 /// <param name="SaleUnit">Unit of Sale</param>
 /// <param name="ChargeToChild">Charge to child per unit</param>
 ///<remarks>
 /// <para>This form of <c>setSaleQuantity</c> is provided as a convenience method
 /// that is functionally equivalent to the method <c>AddSaleQuantity</c></para>
 /// <para>Version: 2.6</para>
 /// <para>Since: 2.0</para>
 /// </remarks>
 public void AddSaleQuantity(decimal?Value, MealStatus MealStatus, string SaleUnit, MonetaryAmount ChargeToChild)
 {
     AddChild(FoodDTD.SALEQUANTITIES_SALEQUANTITY, new SaleQuantity(Value, MealStatus, SaleUnit, ChargeToChild));
 }
Beispiel #22
0
 /// <summary>
 /// Constructor that accepts values for all mandatory fields
 /// </summary>
 ///<param name="refId">GUID for this transaction. The application that owns this object is responsible for generating this unique ID.</param>
 ///<param name="entityId">ID of the entity related to this billing activity (e.g. student ID, employee ID, organization, etc.)</param>
 ///<param name="billingRefId">A pointer back to the Billing object.</param>
 ///<param name="receivedDate">Date payment was received.</param>
 ///<param name="transactionDescription">Description of the transaction.</param>
 ///<param name="receivedAmount">Amount received.</param>
 ///<param name="receivedTransactionId">Memo transaction ID from other vendor software.</param>
 ///
 public Payment(string refId, string entityId, string billingRefId, DateTime?receivedDate, string transactionDescription, MonetaryAmount receivedAmount, string receivedTransactionId) : base(Adk.SifVersion, HrfinDTD.PAYMENT)
 {
     this.RefId                  = refId;
     this.EntityId               = entityId;
     this.BillingRefId           = billingRefId;
     this.ReceivedDate           = receivedDate;
     this.TransactionDescription = transactionDescription;
     this.ReceivedAmount         = receivedAmount;
     this.ReceivedTransactionId  = receivedTransactionId;
 }
Beispiel #23
0
 ///<summary>Adds the value of the <c>&lt;FineInfo&gt;</c> element.</summary>
 /// <param name="Type">Type of fine assessed to this patron and item.  A corresponding ItemInfo is required for all FineInfo types except "Other" and "Refund" where it is permissible to omit the ItemInfo element if there isn't an item associated with the fine.</param>
 /// <param name="Assessed">The date and time that this fine was assessed to the patron.</param>
 /// <param name="Amount">The current balance of the fine expressed as a positive number. </param>
 ///<remarks>
 /// <para>This form of <c>setFineInfo</c> is provided as a convenience method
 /// that is functionally equivalent to the method <c>AddFineInfo</c></para>
 /// <para>Version: 2.6</para>
 /// <para>Since: 1.1</para>
 /// </remarks>
 public void AddFineInfo(FineType Type, DateTime?Assessed, MonetaryAmount Amount)
 {
     AddChild(LibraryDTD.FINEINFOLIST_FINEINFO, new FineInfo(Type, Assessed, Amount));
 }
Beispiel #24
0
 /// <summary>
 /// Constructor that accepts values for all mandatory fields
 /// </summary>
 ///<param name="type">Type of fine assessed to this patron and item.  A corresponding ItemInfo is required for all FineInfo types except "Other" and "Refund" where it is permissible to omit the ItemInfo element if there isn't an item associated with the fine.</param>
 ///<param name="assessed">The date and time that this fine was assessed to the patron.</param>
 ///<param name="amount">The current balance of the fine expressed as a positive number. </param>
 ///
 public FineInfo(FineType type, DateTime?assessed, MonetaryAmount amount) : base(LibraryDTD.FINEINFO)
 {
     this.SetType(type);
     this.Assessed = assessed;
     this.Amount   = amount;
 }
 /// <summary>
 /// Constructor that accepts values for all mandatory fields
 /// </summary>
 ///<param name="libraryType">A library-defined language-independent value that refers to a specific patron type.</param>
 ///<param name="sifRefId">The SIF wide unique identifier of a student or teacher.</param>
 ///<param name="sifRefObject">The type of patron mapped to a SIF supported object. Library automation products work with patrons who could be students or teachers.</param>
 ///<param name="electronicIdList">This is an open list with no primary key.</param>
 ///<param name="numberOfCheckouts">The total number of items that this patron currently has checked out including overdue items.</param>
 ///<param name="numberOfOverdues">The total number of checkouts that are currently overdue.</param>
 ///<param name="numberOfFines">The total number of fines currently assessed to this patron.</param>
 ///<param name="fineAmount">The total monetary amount of the fines that this patron currently owes the library expressed as a positive number.</param>
 ///
 public LibraryPatronStatus(string libraryType, string sifRefId, PatronType sifRefObject, ElectronicIdList electronicIdList, int?numberOfCheckouts, int?numberOfOverdues, int?numberOfFines, MonetaryAmount fineAmount) : base(Adk.SifVersion, LibraryDTD.LIBRARYPATRONSTATUS)
 {
     this.LibraryType = libraryType;
     this.SIF_RefId   = sifRefId;
     this.SetSIF_RefObject(sifRefObject);
     this.ElectronicIdList  = electronicIdList;
     this.NumberOfCheckouts = numberOfCheckouts;
     this.NumberOfOverdues  = numberOfOverdues;
     this.NumberOfFines     = numberOfFines;
     this.FineAmount        = fineAmount;
 }
Beispiel #26
0
 /// <summary> Full constructor. </summary>
 public Bid(MonetaryAmount amount, Item item, User bidder)
 {
     this.amount = amount;
     this.item = item;
     this.bidder = bidder;
 }
 ///<summary>Adds the value of the <c>&lt;BudgetAccount&gt;</c> element.</summary>
 /// <param name="AccountClass">Classification of budgetary account code summary</param>
 /// <param name="FunctionBreakdown">Function breakdown of account code for summarization.</param>
 /// <param name="BudgetAmount">Summarized, positive amount without cents for breakdowns</param>
 ///<remarks>
 /// <para>This form of <c>setBudgetAccount</c> is provided as a convenience method
 /// that is functionally equivalent to the method <c>AddBudgetAccount</c></para>
 /// <para>Version: 2.6</para>
 /// <para>Since: 1.5r1</para>
 /// </remarks>
 public void AddBudgetAccount(AccountClass AccountClass, string FunctionBreakdown, MonetaryAmount BudgetAmount)
 {
     AddChild(HrfinDTD.BUDGETACCOUNTS_BUDGETACCOUNT, new BudgetAccount(AccountClass, FunctionBreakdown, BudgetAmount));
 }
Beispiel #28
0
 ///<summary>Adds the value of the <c>&lt;ExpenseAccount&gt;</c> element.</summary>
 /// <param name="AccountCode">Account code charged to this item.</param>
 /// <param name="Amount">Amount charged to this account.</param>
 ///<remarks>
 /// <para>This form of <c>setExpenseAccount</c> is provided as a convenience method
 /// that is functionally equivalent to the method <c>AddExpenseAccount</c></para>
 /// <para>Version: 2.6</para>
 /// <para>Since: 2.0</para>
 /// </remarks>
 public void AddExpenseAccount(string AccountCode, MonetaryAmount Amount)
 {
     AddChild(HrfinDTD.EXPENSEACCOUNTS_EXPENSEACCOUNT, new ExpenseAccount(AccountCode, Amount));
 }
Beispiel #29
0
 /// <summary>
 /// MonetaryAmountOrNumber as a MonetaryAmount.
 /// </summary>
 /// <param name="monetaryAmount">MonetaryAmountOrNumber as a MonetaryAmount.</param>
 public MonetaryAmountOrNumber(MonetaryAmount monetaryAmount)
     : base(monetaryAmount.Value.AsText)
 {
     AsMonetaryAmount = monetaryAmount;
 }
Beispiel #30
0
 /// <summary>
 /// Constructor that accepts values for all mandatory fields
 /// </summary>
 ///<param name="refId">GUID for this transaction. The application that owns this object is responsible for generating this unique ID.</param>
 ///<param name="billedEntity">A BilledEntity</param>
 ///<param name="entityId">ID of the entity being billed for this billing activity (e.g. student ID, employee ID, organization, etc.)</param>
 ///<param name="billingDate">Date of the transaction.</param>
 ///<param name="transactionDescription">Description of the transaction.</param>
 ///<param name="billedAmount">Amount to be billed.</param>
 ///
 public Billing(string refId, BilledEntity billedEntity, string entityId, DateTime?billingDate, string transactionDescription, MonetaryAmount billedAmount) : base(Adk.SifVersion, HrfinDTD.BILLING)
 {
     this.RefId                  = refId;
     this.BilledEntity           = billedEntity;
     this.EntityId               = entityId;
     this.BillingDate            = billingDate;
     this.TransactionDescription = transactionDescription;
     this.BilledAmount           = billedAmount;
 }
Beispiel #31
0
 /// <summary>
 /// Constructor that accepts values for all mandatory fields
 /// </summary>
 ///<param name="type">Type of pay</param>
 ///<param name="amount">Pay amount.</param>
 ///<param name="percentage">Percentage of pay this represents.</param>
 ///
 public PayRate(PayRateType type, MonetaryAmount amount, decimal?percentage) : base(HrfinDTD.PAYRATE)
 {
     this.SetType(type);
     this.Amount     = amount;
     this.Percentage = percentage;
 }
 public static DecimalDollars ToDecimalDollars(this MonetaryAmount a) =>
 new DecimalDollars(a.Microdollars / 1000000m);
 public static DollarCents ToDollarCents(this MonetaryAmount a) =>
 a.ToDecimalDollars().ToDollarCents;
Beispiel #34
0
 /// <summary>
 /// Constructor that accepts values for all mandatory fields
 /// </summary>
 ///<param name="accountType">Classification of budgetary account code summary</param>
 ///<param name="fundType">Is the account a general or special account code designation?</param>
 ///<param name="function">Function break in account code for summarization.</param>
 ///<param name="amount">Summarized amount.</param>
 ///
 public AnnualItem(AccountClass accountType, FundType fundType, string function, MonetaryAmount amount) : base(HrfinDTD.ANNUALITEM)
 {
     this.SetAccountType(accountType);
     this.SetFundType(fundType);
     this.Function = function;
     this.Amount   = amount;
 }
Beispiel #35
0
 /// <summary>
 /// Constructor that accepts values for all mandatory fields
 /// </summary>
 ///<param name="accountClass">Classification of budgetary account code summary</param>
 ///<param name="functionBreakdown">Function breakdown of account code for summarization.</param>
 ///<param name="budgetAmount">Summarized, positive amount without cents for breakdowns</param>
 ///
 public BudgetAccount(AccountClass accountClass, string functionBreakdown, MonetaryAmount budgetAmount) : base(HrfinDTD.BUDGETACCOUNT)
 {
     this.SetAccountClass(accountClass);
     this.FunctionBreakdown = functionBreakdown;
     this.BudgetAmount      = budgetAmount;
 }