Bill Button in Purchase Order
i have a requirement to automate logic in the BILL button displayed in purchase order form. i have tried the below code
CashSale cSale = new CashSale();
cSale.createdFrom = new RecordRef { internalId = "XXXXXXXX", type = RecordType.salesOrder, typeSpecified = true };
cSale.entity = new RecordRef { internalId = "XXXXXX", type = RecordType.customer, typeSpecified = true };
cSale.tranDate = System.DateTime.Now;
cSale.location = new RecordRef { internalId = "1", name = "XXXX", type = RecordType.location, typeSpecified = true };
string postingPeriod = String.Format("{0:MMMM}", DateTime.Now) + " " + DateTime.Now.Year;
cSale.postingPeriod = new RecordRef { name = postingPeriod};
CashSaleItemList cSaleItemList = new CashSaleItemList();
CashSaleItem[] cSaleItems = new CashSaleItem[1];
CashSaleItem csItem = new CashSaleItem();
RecordRef roItem = new RecordRef();
roItem.type = RecordType.inventoryItem;
roItem.typeSpecified = true;
roItem.internalId = "XXXXX";
csItem.item = roItem;
RecordRef prLevel = new RecordRef();
prLevel.type = RecordType.priceLevel;
prLevel.internalId = "-1";
prLevel.typeSpecified = true;
csItem.price = prLevel;
csItem.rate = "15";
csItem.quantity = 1;
csItem.quantitySpecified = true;
InventoryAssignment iAssignment = new InventoryAssignment
{
binNumber = new RecordRef { internalId = "XXXX", type = RecordType.bin, typeSpecified = true },
quantity = 1,
quantitySpecified = true
};
List<InventoryAssignment> iAssignmentList = new List<InventoryAssignment>();
iAssignmentList.Add(iAssignment);
csItem.inventoryDetail = new InventoryDetail
{
inventoryAssignmentList = new InventoryAssignmentList
{
inventoryAssignment = iAssignmentList.ToArray()
}
};
cSaleItems[0] = csItem;
cSaleItemList.item = cSaleItems;
cSale.itemList = cSaleItemList;
WriteResponse response = Service.add(cSale);
if (response.status.isSuccess != true) throw new Exception(response.status.statusDetail[0].message);
This creates record of type Cash Sale and link type Order Bill/Invoice. But i want to create record of type Bill and link type Order Bill/Invoice.
Searched for the C# code. can’t find it.Can anyone provide me a code in C# to perform the same action as BILL button in the purchase order form?
Thanks in Advance.