Adding Bin/Lot/Serial item to Acumatica shipment lines
I are able to create an Acumatica shipment through Web Services, but getting an issue in adding Bin/Lot Number for each line in the grid. If I have only one document detail line in shipment, it is working fine, but when there is more than one line in document details, the code does not seem to be working. Please find below the Acumatica code that I am using to achieve this.
SO302000Content soShipcontent = content.SO302000GetSchema();
List<Command> scmds = new List<Command>();
List<LineDetails> splits = new List<LineDetails>();
CreateShipmentHeader(soShipcontent, hparams, ref scmds, Ordernumber);
var shipmentresults = content.SO302000Submit(scmds.ToArray());
if (shipmentresults != null && shipmentresults.Length > 0)
{
int linen = 0;
List<Command> cmds = new List<Command>();
foreach (var row in shipmentresults)
{
SO302000Content c = (SO302000Content)row;
cmds.Add(new Value { Value = linen.ToString(), LinkedCommand = soShipcontent.AddSalesOrder.ServiceCommands.RowNumber });
cmds.Add(new Value { Value = "True", LinkedCommand = soShipcontent.AddSalesOrder.Selected, Commit = true });
LineDetails ld = details.Find(x => x.InventoryId == c.AddSalesOrder.InventoryID.Value.ToString().Trim());
if (ld != null)
{
LineDetails splitno = new LineDetails();
splitno.InventoryId = ld.InventoryId;
splitno.Location = ld.Location;
splitno.LotNo = ld.LotNo;
splitno.Quantity = c.AddSalesOrder.Quantity.Value.ToString().Trim();
splitno.LineNumber = (linen).ToString();
splits.Add(splitno);
}
linen++;
}
cmds.Add(soShipcontent.Actions.AddSO);
content.SO302000Submit(cmds.ToArray());
foreach (LineDetails s in splits)
{
List<Command> cmdsplit = new List<Command>();
cmdsplit.Add(new Value { Value = s.LineNumber, LinkedCommand = soShipcontent.BinLotSerialNumbers.ServiceCommands.RowNumber });
cmdsplit.Add(new Value { Value = s.InventoryId, LinkedCommand = soShipcontent.BinLotSerialNumbers.InventoryID, Commit = true });
cmdsplit.Add(new Value { Value = s.Location, LinkedCommand = soShipcontent.BinLotSerialNumbers.Location, Commit = true });
cmdsplit.Add(new Value { Value = s.LotNo, LinkedCommand = soShipcontent.BinLotSerialNumbers.LotSerialNbr });
cmdsplit.Add(new Value { Value = s.Quantity, LinkedCommand = soShipcontent.BinLotSerialNumbers.Quantity });
content.SO302000Submit(cmdsplit.ToArray());
}
}
List<Command> cmds1 = new List<Command>();
string shipmentnbr = string.Empty;
cmds1.Add(soShipcontent.Actions.Save);
cmds1.Add(soShipcontent.ShipmentSummary.ShipmentNbr);
content.SO302000Submit(cmds1.ToArray());
I have tried below code also:
cmds.Add(soShipcontent.BinLotSerialNumbers.ServiceCommands.NewRow);
cmdsplit.Add(new Value { Value = s.Location, LinkedCommand = soShipcontent.BinLotSerialNumbers.Location});
cmdsplit.Add(new Value { Value = s.LotNo, LinkedCommand = soShipcontent.BinLotSerialNumbers.LotSerialNbr });
cmdsplit.Add(new Value { Value = s.Quantity, LinkedCommand = soShipcontent.BinLotSerialNumbers.Quantity, Commit = true });
cmdsplit.Add(new Value { Value = s.InventoryId, LinkedCommand = soShipcontent.BinLotSerialNumbers.InventoryID });
cmdsplit.Add(new Key { Value = "='" + s.InventoryId + "'", FieldName = soShipcontent.DocumentDetails.InventoryID.FieldName, ObjectName = soShipcontent.DocumentDetails.InventoryID.ObjectName });
Actually i'm not really following your code but i would say that acumatica an assign SN automatically depends on the item settings. Otherwise you can manually assign SN.
The most simplest example is when you have qty = 1 on the detail level, see code below
Content[] result = context.Submit(
new Command[]
{
new Value { Value = "000200", LinkedCommand = SO302000.ShipmentSummary.ShipmentNbr, Commit = true },
//navigate to line
new Key
{
ObjectName = SO302000.DocumentDetails.InventoryID.ObjectName,
FieldName = SO302000.DocumentDetails.InventoryID.FieldName,
Value = "='INCLUTA009'"
},
new Value { Value = "20SP0610", LinkedCommand = SO302000.DocumentDetails.LotSerialNbr, Commit = true },
SO302000.Actions.Save
}
);
Related
Why does the head change here?
I thought assigning oddPointer to head would allow me to traverse through the list without changing head. This does not seem to be the case. When I log(head) it appears as 1->3->5, why is it not 1->2->3->4->5?
Is there a way to complete this without changing head?
// JavaScript
var oddEvenList = function (head) {
let oddList = new ListNode(-1);
let oddCopy = oddList;
let cnt = 0;
let oddPointer = head;
while (oddPointer) {
cnt++;
if (cnt % 2 !== 0) {
oddList.next = oddPointer; // -1,1,3,5
oddList = oddList.next;
}
oddPointer = oddPointer.next;
}
console.log(oddList);
console.log(oddCopy);
console.log(head);
console.log(oddPointer);
return -1;
}
function ListNode(val, next) {
this.val = (val === undefined ? 0 : val)
this.next = (next === undefined ? null : next)
}
let a1 = new ListNode(1);
let a2 = new ListNode(2);
let a3 = new ListNode(3);
let a4 = new ListNode(4);
let a5 = new ListNode(5)
a1.next = a2;
a2.next = a3;
a3.next = a4;
a4.next = a5;
console.log(oddEvenList(a1));
Hi I am facing issue in update records in MVC. I have created one list view model and in that i want to update some of the records but i am getting error. Please help me.
Here is my code:
public async Task<bool> AddPurchase(PurchaseOrderViewModel objModel, List<TableViewModel> tableListDto)
{
using (var txn = context.Database.BeginTransaction())
{
bool success = true;
try
{
PurchaseOrder purchase1 = new PurchaseOrder();
purchase1.LoginID = objModel.LoginID;
purchase1.SupplierID = objModel.SupplierID;
purchase1.SupplierName = objModel.SupplierName;
purchase1.LocationID = objModel.LocationID;
purchase1.Notes = objModel.Notes;
purchase1.Currency = objModel.Currency;
purchase1.TotalQuantity = objModel.TotalQuantity;
purchase1.TotalAmount = objModel.TotalAmount;
purchase1.TotalVolume = objModel.TotalVolume;
purchase1.TotalWeight = objModel.TotalWeight;
purchase1.TotalLandedCost = Convert.ToDecimal(objModel.TotalCost);
purchase1.TotalOtherCost = objModel.TotalOtherCost;
purchase1.Date_Of_Purchase = objModel.Date_Of_Purchase;
purchase1.Due_Date = objModel.Due_Date;
purchase1.Date_Arrived = objModel.Date_Arrived;
purchase1.Date_Departed = objModel.Date_Departed;
purchase1.CreatedBy = objModel.LoginID;
purchase1.CreatedOn = objModel.CreatedOn;
purchase1.UpdatedBy = objModel.LoginID;
purchase1.UpdatedOn = objModel.UpdatedOn;
purchase1.Status = StatusConstant.Active;
context.PurchaseOrders.Add(purchase1);
await context.SaveChangesAsync();
success = true;
int latest = purchase1.PurchaseID;
PO_Landed_Cost cost = new PO_Landed_Cost();
cost.LoginID = objModel.LoginID;
cost.PurchaseID = latest;
cost.Packaging_Costs = objModel.Packaging_Cost;
cost.Packaging_Costs_Date_Paid = objModel.Packaging_Costs_Date_Paid;
cost.Inspection_Costs = objModel.Inspection_Cost;
cost.Inspection_Costs_Date_Paid = objModel.Inspection_Costs_Date_Paid;
cost.Freight_And_Duty_Tax = objModel.Freight_Cost;
cost.Freight_And_Duty_Tax_Date_Paid = objModel.Freight_And_Duty_Tax_Date_Paid;
cost.Other_Costs = objModel.Other_Cost;
cost.Total_Landed_Cost = objModel.TotalOtherCost;
context.PO_Landed_Costs.Add(cost);
context.SaveChanges();
OrderDetail order = new OrderDetail();
PO_Landed_Cost_Spread spread1 = new PO_Landed_Cost_Spread();
List<DataDisplayViewModel> data = new List<DataDisplayViewModel>();
if (tableListDto != null)
{
foreach (var item in tableListDto)
{
//First we take all the basic things
var a = Convert.ToDecimal(item.Qty); //Quantity
var b = Convert.ToDecimal(purchase1.TotalQuantity); //Total Quantity
var e = Convert.ToDecimal(objModel.TotalOtherCost); //TotalOtherCost
var g = Convert.ToDecimal(item.Price); //Price
var j = Convert.ToDecimal(item.Volume); //Volume
var l = Convert.ToDecimal(item.Weight); //Weight
var c = Math.Round(Convert.ToDecimal((a / b) * 100), 2); //Total Percent(Quantity)
var f = Math.Round(Convert.ToDecimal(((c * e) / a) / 100), 2); // Quantity Unit Price(Indirect Cost)
var h = Math.Round(Convert.ToDecimal(f + g), 2); //Landed Cost Unit Price (Quantity)
var i = Math.Round(Convert.ToDecimal(h * a), 2); //New Total (Quantity)
var k = Math.Round(Convert.ToDecimal(a * j), 2); //Total Volume
var m = Math.Round(Convert.ToDecimal(a * l), 2); //Total Weight
DataDisplayViewModel datalist = new DataDisplayViewModel();
datalist.LoginID = objModel.LoginID;
datalist.PurchaseID = latest;
datalist.Stock_ID = item.Pid;
datalist.Stock_Name = item.ProductName;
datalist.Quantity = Convert.ToInt32(item.Qty);
datalist.Price = Convert.ToDecimal(item.Price);
datalist.Amount = Convert.ToDecimal(item.Amount);
datalist.Volume = Convert.ToInt32(item.Volume);
datalist.Total_Volume = Convert.ToInt32(k);
datalist.Weight = Convert.ToInt32(item.Weight);
datalist.Total_Weight = Convert.ToInt32(m);
datalist.Total_Percent = Convert.ToString(c);
datalist.Indirect_Cost_UnitPrice = Convert.ToString(f);
datalist.Landed_Cost_UnitPrice = Convert.ToString(h);
datalist.New_Amount = i;
data.Add(datalist);
}
var totalweight = data.Where(x => x.PurchaseID == latest).Select(x => x.Total_Weight).Sum();
var totalvolume = data.Where(x => x.PurchaseID == latest).Select(x => x.Total_Volume).Sum();
foreach (var item in tableListDto)
{
var z = Convert.ToInt32(item.Price);
var a = Convert.ToInt32(item.Qty); //Qty
var l = Convert.ToDecimal(item.Weight); //Weight
var j = Convert.ToDecimal(item.Volume); //Volume
var d = Math.Round(Convert.ToDecimal(((a * l) / totalweight) * 100), 2); //Total Percent Of Weight
var e = Convert.ToInt32(objModel.TotalOtherCost); //Total Other Cost
var f = Math.Round(Convert.ToDecimal(((d * e) / a) / 100), 2);
var h = Convert.ToDecimal(a + f); // Landed Cost Unit Price Of Weight
var i = Convert.ToString(h * a); // New Total Of Weight
var m = (a * j / totalvolume) * 100; //Total Percent Of Volume
var o = Math.Round(Convert.ToDecimal(((m * e) / a) / 100), 2); //Unit Price Of Volume
var q = Math.Round(Convert.ToDecimal(z + o), 2); // Landed Cost Unit Price Of Volume
var r = Convert.ToInt32(q * a); //New Total Of Volume
data.Where(x => x.PurchaseID == latest).FirstOrDefault();
data.Where(x => x.PurchaseID == latest).FirstOrDefault().Indirect_Cost_WeightUnitPrice = Convert.ToString(f);
data.Where(x => x.PurchaseID == latest).FirstOrDefault().Landed_Cost_WeightUnitPrice = Convert.ToString(h);
data.Where(x => x.PurchaseID == latest).FirstOrDefault().New_WeightAmount = Convert.ToDecimal(i);
data.Where(x => x.PurchaseID == latest).FirstOrDefault().Total_Percent_Volume = Convert.ToString(m);
data.Where(x => x.PurchaseID == latest).FirstOrDefault().Indirect_Cost_VolumeUnitPrice = Convert.ToString(o);
data.Where(x => x.PurchaseID == latest).FirstOrDefault().Landed_Cost_VolumeUnitPrice = Convert.ToString(q);
data.Where(x => x.PurchaseID == latest).FirstOrDefault().New_VolumeAmount = Convert.ToDecimal(r);
context.Entry(data).State = EntityState.Added;
context.SaveChanges();
}
foreach (var item in data)
{
order.LoginID = objModel.LoginID;
order.PurchaseID = item.PurchaseID;
order.Stock_ID = item.Stock_ID;
order.Quantity = item.Quantity;
order.Price = item.Price;
order.Amount = item.Amount;
order.CreatedBy = objModel.LoginID;
order.CreatedOn = objModel.CreatedOn;
order.UpdatedBy = objModel.LoginID;
order.UpdatedOn = objModel.UpdatedOn;
order.Status = StatusConstant.Active;
order.Stock_Name = item.Stock_Name;
order.Volume = item.Volume;
order.Total_Volume = item.Total_Volume;
order.Weight = item.Weight;
order.Total_Weight = item.Total_Weight;
context.OrderDetails.Add(order);
context.SaveChanges();
spread1.PurchaseID = item.PurchaseID;
spread1.OrderID = order.OrderID;
spread1.LoginID = item.LoginID;
spread1.Total_Percent = item.Total_Percent;
spread1.Indirect_Cost_UnitPrice = item.Indirect_Cost_UnitPrice;
spread1.Landed_Cost_UnitPrice = item.Landed_Cost_UnitPrice;
spread1.New_Amount = item.New_Amount;
spread1.Total_Percent_Volume = item.Total_Percent_Volume;
spread1.Indirect_Cost_VolumeUnitPrice = item.Indirect_Cost_VolumeUnitPrice;
spread1.Landed_Cost_VolumeUnitPrice = item.Landed_Cost_VolumeUnitPrice;
spread1.New_VolumeAmount = item.New_VolumeAmount;
spread1.Total_Percent_Weight = item.Total_Percent_Weight;
spread1.Indirect_Cost_WeightUnitPrice = item.Indirect_Cost_WeightUnitPrice;
spread1.Landed_Cost_WeightUnitPrice = item.Landed_Cost_WeightUnitPrice;
spread1.New_WeightAmount = item.New_WeightAmount;
context.PO_Landed_Cost_Spreads.Add(spread1);
context.SaveChanges();
}
}
else
{
order.LoginID = objModel.LoginID;
order.PurchaseID = latest;
order.CreatedBy = objModel.LoginID;
order.CreatedOn = objModel.CreatedOn;
order.UpdatedBy = objModel.LoginID;
order.UpdatedOn = objModel.UpdatedOn;
order.Status = StatusConstant.Active;
context.OrderDetails.Add(order);
context.SaveChanges();
PO_Landed_Cost_Spread spread = new PO_Landed_Cost_Spread();
spread.LoginID = objModel.LoginID;
spread.PurchaseID = latest;
spread.OrderID = order.OrderID;
context.PO_Landed_Cost_Spreads.Add(spread);
context.SaveChanges();
}
txn.Commit();
}
catch (Exception ex)
{
txn.Dispose();
success = false;
}
return success;
};
}
In this code i want to update records when first i need to find some values and then i need to update in the list view model and then i need to update in the table. But i am unable to do that. Please help me in this.
I am working on integrating quick books with mvc and I have to work on one task which is to check if enabling custom invoice numbers results in duplicate Invoice .
I have tried creating invoice in quick books
public Invoice PostInvoice(InvoiceViewModel model)
{
Intuit.Ipp.Data.Invoice invoice = new Intuit.Ipp.Data.Invoice();
invoice.Deposit = new Decimal(0.00);
invoice.DepositSpecified = true;
invoice.DocNumber = "QBOInvoice" + DateTime.Now.ToString("MMddHHmmss");
invoice.CustomerRef = new ReferenceType { Value = model.qboCustomer.Id };
// invoice.CustomerMemo = new MemoRef { Value = reference };
invoice.DueDate = DateTime.UtcNow.Date;
invoice.DueDateSpecified = true;
invoice.TotalAmtSpecified = true;
invoice.ApplyTaxAfterDiscount = false;
invoice.ApplyTaxAfterDiscountSpecified = true;
invoice.PrintStatus = PrintStatusEnum.NotSet;
invoice.PrintStatusSpecified = true;
invoice.EmailStatus = EmailStatusEnum.NotSet;
invoice.EmailStatusSpecified = true;
invoice.BalanceSpecified = true;
invoice.TxnDate = DateTime.UtcNow.Date;
invoice.TxnDateSpecified = true;
invoice.ShipAddr = model.Address;
invoice.BillAddr = model.Address; //new PhysicalAddress() { Line1 = "BillMohali", Line2 = "Sector 70 ", City = "Mohali", PostalCode = "160071" };
//invoice.ShipAddr = new PhysicalAddress() {Line1="Mohali", Line2="Sector 70 ",City="Mohali",PostalCode="160071" };
//invoice.BillAddr = new PhysicalAddress() { Line1 = "BillMohali", Line2 = "Sector 70 ", City = "Mohali", PostalCode = "160071" };
Intuit.Ipp.Data.Line line = new Intuit.Ipp.Data.Line();
SalesItemLineDetail lineSalesItemLineDetail = new SalesItemLineDetail();
List<Intuit.Ipp.Data.Line> lineList = new List<Intuit.Ipp.Data.Line>();
foreach (var item in model.qbolineitems)
{
lineSalesItemLineDetail = new SalesItemLineDetail();
line = new Intuit.Ipp.Data.Line();
//Line Sales Item Line Detail - ServiceDate
lineSalesItemLineDetail.ServiceDate = DateTime.Now.Date;
lineSalesItemLineDetail.ServiceDateSpecified = true;
lineSalesItemLineDetail.Qty = item.invoiceitem.quantity.Value;
lineSalesItemLineDetail.QtySpecified = true;
lineSalesItemLineDetail.ItemRef = new ReferenceType { Value = item.item.qboItemCode.Value.ToString(), name = item.item.qboItemName };
lineSalesItemLineDetail.AnyIntuitObject = item.invoiceitem.SalePrice.Value / item.invoiceitem.quantity.Value;
lineSalesItemLineDetail.ItemElementName = ItemChoiceType.UnitPrice;
line.AnyIntuitObject = lineSalesItemLineDetail;
line.Description = item.item.qboItemName;
line.Amount = item.invoiceitem.SalePrice.Value;
line.AmountSpecified = true;
// line.Id = item.item.qboItemCode.Value.ToString();
line.DetailType = LineDetailTypeEnum.SalesItemLineDetail;
line.DetailTypeSpecified = true;
//if (_connect.Country == "US")
//{
lineSalesItemLineDetail.TaxInclusiveAmt = item.invoiceitem.SalePrice.Value;
lineSalesItemLineDetail.TaxCodeRef = new ReferenceType { Value = "TAX" };
//}
//else
//{
//_connect = (Connect)Session["Connect"];
// objQBO = new QBOWrapper("jagjeetkr7#gmail.com", Request.Url.GetLeftPart(UriPartial.Authority) + "/Home/Callback", _connect, true);
//var taxcode = objQBO.getTaxCodeList().Where(x => x.Active).FirstOrDefault();
//lineSalesItemLineDetail.TaxCodeRef = new ReferenceType { Value = taxcode.Id };
//var dis = item.invoiceitem.SalePrice.Value / (Convert.ToDecimal(taxcode.SalesTaxRateList.TaxRateDetail[0].TaxRateRef.Value) + 1);
//line.Amount = item.invoiceitem.SalePrice.Value - dis;
//lineSalesItemLineDetail.TaxInclusiveAmt = item.invoiceitem.SalePrice.Value;
lineSalesItemLineDetail.TaxInclusiveAmtSpecified = false;
invoice.GlobalTaxCalculationSpecified = false;
invoice.GlobalTaxCalculation = GlobalTaxCalculationEnum.NotApplicable;
//SendInsideFunctionEmail("Failed to create surcharge invoice for : " + reference, "Please create a surcharge invoice manually and send a receipt to the customer. Also,please assign the tax code for this account selected in qbo.", _generalSettings.AccountsEmail);
// }
lineList.Add(line);
}
//invoice.TotalAmt = new Decimal(0.90);
//invoice.Balance = new Decimal(0.90);
// xlic.Add(li);
invoice.TotalAmt = model.Total;
invoice.Balance = model.BalanceDue;
invoice.Line = lineList.ToArray();
_connect = (Connect)Session["Connect"];
objQBO = new QBOWrapper("jagjeetkr7#gmail.com", Request.Url.GetLeftPart(UriPartial.Authority) + "/Home/Callback", _connect, true);
//objQBO = new QBOWrapper("jagjeetkr7#gmail.com", Request.Url.GetLeftPart(UriPartial.Authority) + "/Home/Callback", _connect, true);
invoice = objQBO.CreateInvoice(invoice);
return invoice;
}
I expect that generating custom invoice numbers results in duplicate invoice but not finding a way to implement that
I'm trying to sort a table for a addon/weakaura but I do not see how to do it ( sort by the attribut value).
Example :
player = {
value = 34
class = Warrior,
id = 1
},
{
value = 1,
class = mage,
id = 2
},
{
value = 3443,
class = Paladin,,
class = 3
}
I want :
player = {
value = 1,
class = mage,
id = 2
},
{
value = 34
class = Warrior,
id = 1
},
{
value = 3443,
class = Paladin,
class = 3
}
Someone an idea how to do this ?
Assuming you fix your table declaration, you can sort the table using a custom function:
local player = {
{ value = 34, class = "Warrior", id = 1 },
{ value = 1, class = "mage", id = 2 },
{ value = 3443, class = "Paladin", id = 3 },
}
table.sort(player, function(a,b) return a.value < b.value end)
This will sort elements of the player table by the value of the value field. You can come up with a more elaborate sorting condition if needed.
Refer to http://www.lua.org/manual/5.3/manual.html#pdf-table.sort for more information on table.sort
How to sort the items within each stacking column? Asc or desc.
Each series added to a chart is drawn on the chart in the order it was received. To change the order of the chart series you will need to change which series is the first in your list of series items.
That being said - what I think you want to do is to, independently of the series order, sort on each stack by value. I do not think this is possible in HighCharts.
You can only set global index of serie, but you cannot position each single "stack".
http://api.highcharts.com/highcharts#series.index
You may use the script below to sort the Stacked Chart Bars by category name.
var sortData = function(chartSource) {
var series = chartSource.series;
var axis = chartSource.xAxis[0];
var categories = [];
if($.isArray(series)) {
var ser =
$.grep(series, function(ser, seriesIndex)
{
return ser.visible;
})[0];
$.each(ser.data,
function(dataIndex, datum)
{
console.log(datum.category + ':' + datum.stackTotal);
var obj = {
name: datum.category,
index: dataIndex,
stackTotal: datum.stackTotal
}
categories.push(obj);
}
);
}
categories.sort(function(a, b) {
var aName = a.name.toLowerCase();
var bName = b.name.toLowerCase();
var aTotal = a.stackTotal;
var bTotal = b.stackTotal;
//if(aTotal === bTotal) {
return ((aName < bName) ? -1 : ((aName > bName) ? 1 : 0));
//} else {
// return ((aTotal > bTotal) ? -1 : ((aTotal < bTotal) ? 1 : 0));
//}
});
var mappedIndex = $.map(categories, function(category, index) {
return category.index;
});
categories = $.map(categories, function(category, index) {
return category.name;
});
console.log(categories);
console.log(mappedIndex);
axis.setCategories(categories);
var newDataArray = [];
$.each(series, function(seriesIndex, ser) {
newDataArray = [];
var data = $.map(mappedIndex, function(mappedIndex2, origIndex) {
var ydata = ser.data[mappedIndex2];
if(ydata.y!=null){
var y = ydata.y
newDataArray.push(y);
return y;
}
else
{
newDataArray.push(null);
return null;
}
});
ser.setData(newDataArray);
});
};