MaximumInvoice


Description

Contains information about the maximum invoice for a vendor.

Properties

Property

Type

Length

Default

Description

Item

Choice

N/A

N/A

A choice type that contains either a MoneyAmount or a MaximumInvoiceSpecialAmount.


Examples

The following C# example demonstrates how to retrieve the Item property of a MaximumInvoice object and determine whether it is a money amount or a maximum invoice special amount. Note how the GetType() function is used to retrieve the underlying type of the Item property, and how the typeof() function is used to retrieve the types for the comparison operation.

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using DynamicsGPWebServiceSample.DynamicsGPService;

namespace DynamicsGPWebServiceSample
{
	class Program
	{
		static void Main(string[] args)
		{
			CompanyKey companyKey;
			Context context;
			Vendor vendor;
			VendorKey vendorKey;
			MaximumInvoice maximumInvoice;
			MoneyAmount maximumInvoiceAmount;
			MaximumInvoiceSpecialAmount maximumInvoiceSpecialAmount;

			// Create an instance of the web service
			DynamicsGP wsDynamicsGP = new DynamicsGP();

			// Be sure the default credentials are used
			wsDynamicsGP.UseDefaultCredentials = true;

			// Create a context object with which to call the web service
			context = new Context();

			// Specify which company to use (sample company)
			companyKey = new CompanyKey();
			companyKey.Id = (-1);

			// Set up the context object
			context.OrganizationKey = (OrganizationKey)companyKey;

			// Create a vendor key
			vendorKey = new VendorKey();
			vendorKey.Id = "ACETRAVE0001";

			// Retrieve the vendor object
			vendor = wsDynamicsGP.GetVendorByKey(vendorKey, context);

			// Examine the maximum invoice information
			maximumInvoice = new MaximumInvoice();
			maximumInvoice = vendor.MaximumInvoice;

			if (maximumInvoice.Item.GetType() == typeof(MoneyAmount))
			{
				maximumInvoiceAmount = (MoneyAmount)maximumInvoice.Item;
				MessageBox.Show("Maximum invoice is an amount of " + maximumInvoiceAmount.Value.ToString());
		}

			if (maximumInvoice.Item.GetType() == typeof(MaximumInvoiceSpecialAmount))
			{
				maximumInvoiceSpecialAmount = (MaximumInvoiceSpecialAmount)maximumInvoice.Item;
				MessageBox.Show("Maximum invoice is a special amount: " +
				maximumInvoiceSpecialAmount.ToString());
		}
	}
}
}

The following C# example shows how the Item property for a vendor maximum invoice can be set to the value in the MaximumInvoiceSpecialAmount enumeration. Notice how the Item property is cast to be of the proper type.

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using DynamicsGPWebServiceSample.DynamicsGPService;

namespace DynamicsGPWebServiceSample
{
	class Program
	{
		static void Main(string[] args)
		{
			CompanyKey companyKey;
			Context context;
			Vendor vendor;
			VendorKey vendorKey;
			MaximumInvoice maximumInvoice;
			Policy vendorUpdatePolicy;

			// Create an instance of the web service
			DynamicsGP wsDynamicsGP = new DynamicsGP();

			// Be sure the default credentials are used
			wsDynamicsGP.UseDefaultCredentials = true;

			// Create a context object with which to call the web service
			context = new Context();

			// Specify which company to use (sample company)
			companyKey = new CompanyKey();
			companyKey.Id = (-1);

			// Set up the context object
			context.OrganizationKey = (OrganizationKey)companyKey;

			// Get the UpdateVendor policy
			vendorUpdatePolicy = wsDynamicsGP.GetPolicyByOperation("UpdateVendor", context);

			// Create a vendor key
			vendorKey = new VendorKey();
			vendorKey.Id = "ACETRAVE0001";

			// Create the vendor object
			vendor = new Vendor();
			vendor.Key = vendorKey;

			// Set the maximum invoice information
			maximumInvoice = new MaximumInvoice();
			maximumInvoice.Item = (MaximumInvoiceSpecialAmount)MaximumInvoiceSpecialAmount.NoMaximum;
			vendor.MaximumInvoice = maximumInvoice;

			// Update the vendor
			wsDynamicsGP.UpdateVendor(vendor, context, vendorUpdatePolicy);
	}
}
}


Documentation Feedback