Quantcast
Channel: Microsoft Dynamics GP Forum - Recent Threads
Viewing all articles
Browse latest Browse all 32807

PaymentAmount does not match line deposit plus +credit card payment total.

$
0
0

Hi,

I am trying to add a payment to a Sales Order, which has a total of $399.96. I receive this error:

PaymentAmount does not match line deposit plus +credit card payment total.

What am I missing? Here is my code:

static void Main(string[] args)
{
CompanyKey companyKey;
Context context;
SalesOrder salesOrder;
SalesDocumentTypeKey salesOrderType;
CustomerKey customerKey;
BatchKey batchKey;
SalesOrderLine salesOrderLine;
ItemKey orderedItem;
Quantity orderedAmount;
Policy salesOrderCreatePolicy;

// CreateItem();
// CreatePriceListForItem();
// CreateItemWarehouse();

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

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

// Create a context with which to call the 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;

//var ws = wsDynamicsGP.GetWarehouseList(new WarehouseCriteria(), context).FirstOrDefault();
//var ws = wsDynamicsGP.GetPriceLevelList(new PriceLevelCriteria(), context);
Policy p = wsDynamicsGP.GetPolicyByOperation("DeleteSalesOrder", context);
wsDynamicsGP.DeleteSalesOrder(new SalesDocumentKey { Id = "ORDST2239" }, context, p);
// Create a sales order object
salesOrder = new SalesOrder();
//var cust = wsDynamicsGP.GetCustomerByKey(new CustomerKey { Id = "ADMINISTRATORGL" }, context);



// Create a sales document type key for the sales order
salesOrderType = new SalesDocumentTypeKey();
salesOrderType.Type = SalesDocumentType.Order;

// Populate the document type key of the sales order object
salesOrder.DocumentTypeKey = salesOrderType;

// Create a customer key
customerKey = new CustomerKey();
customerKey.Id = "ADMINISTRATORGL";

// Set the customer key property of the sales order object
salesOrder.CustomerKey = customerKey;

// Create a batch key
batchKey = new BatchKey();
batchKey.Id = "SALES ORDERS";

// Set the batch key property of the sales order object
salesOrder.BatchKey = batchKey;

// Create a sales order line to specify the ordered item
salesOrderLine = new SalesOrderLine();

// Create an item key
orderedItem = new ItemKey();
orderedItem.Id = "ADI123";

// Set the item key property of the sales order line object
salesOrderLine.ItemKey = orderedItem;
// Create a sales order quantity object
orderedAmount = new Quantity();
orderedAmount.Value = 4;

// Set the quantity of the sales order line object
salesOrderLine.Quantity = orderedAmount;
salesOrderLine.WarehouseKey = new WarehouseKey { Id = "NORTH" };

// Create an array of sales order lines
// Initialize the array with sales order line object
SalesOrderLine[] orders = { salesOrderLine };

// Add the sales order line array to the sales order
salesOrder.Lines = orders;

// Get the create policy for the sales order object
salesOrderCreatePolicy = wsDynamicsGP.GetPolicyByOperation("CreateSalesOrder", context);

salesOrder.PaymentAmount = new MoneyAmount { Value = 399.96M};
// Create the sales order
wsDynamicsGP.CreateSalesOrder(salesOrder, context, salesOrderCreatePolicy);
}


Viewing all articles
Browse latest Browse all 32807

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>