Я добавил поле штрих -кода на экран PO. Функциональность работает нормально, но я сталкиваюсь с проблемой, когда всякий раз, когда я впервые сканирую продукт, OrderQty автоматически устанавливается на 2. Когда я снова сканирую тот же продукт, OrderQty увеличивается до 3, что является правильным. /p>
Но я впервые должен быть 1 не 2. Первое сканирование (вторая линия PO). Я попытался решить эту проблему, но еще не был успешным. >
Вот мой код: < /p>
using PX.Data;
using PX.Objects.PO;
using PX.Objects.IN;
using PX.Objects.CS;
using System.Linq;
namespace PX.Objects.PO
{
public class POOrderEntry_Extension : PXGraphExtension
{
#region Event Handlers
protected virtual void POOrder_UsrInventoryBarCode_FieldUpdated(
PXCache cache,
PXFieldUpdatedEventArgs e,
PXFieldUpdated BaseMethod)
{
// Call base event handler if it exists
BaseMethod?.Invoke(cache, e);
// Get the current POOrder
POOrder order = e.Row as POOrder;
if (order == null) return;
POOrderExt orderExt = cache.GetExtension(order);
if (string.IsNullOrEmpty(orderExt?.UsrInventoryBarCode))
return;
// Lookup the INItemXRef record using the scanned barcode
INItemXRef xRef = PXSelectJoin<
INItemXRef,
InnerJoin,
Where>
.Select(Base, INAlternateType.Barcode, orderExt.UsrInventoryBarCode);
if (xRef == null)
{
throw new PXSetPropertyException(
"Barcode not found in the system.");
}
// Retrieve the InventoryItem from the cross-reference
InventoryItem item = PXSelect<
InventoryItem,
Where>
.Select(Base, xRef.InventoryID);
if (item == null)
{
throw new PXSetPropertyException(
"Inventory Item not found.");
}
// Check vendor compatibility via POVendorInventory
POVendorInventory vendorItem = PXSelect<
POVendorInventory,
Where>
.Select(Base, item.InventoryID);
if (vendorItem != null)
{
if (order.VendorID == null)
{
order.VendorID = vendorItem.VendorID;
cache.RaiseFieldUpdated(order, order.VendorID);
Base.Document.Update(order);
}
else if (order.VendorID != vendorItem.VendorID)
{
throw new PXSetPropertyException(
"Scanned item belongs to a different vendor.");
}
}
// Check if a POLine for this InventoryID already exists (accumulate quantity).
var existingLine = Base.Transactions
.Select()
.RowCast()
.FirstOrDefault(l => l.InventoryID == item.InventoryID);
if (existingLine != null)
{
PXTrace.WriteInformation($"Existing Line Found: {existingLine.InventoryID}, Current Qty: {existingLine.OrderQty}");
if (existingLine.OrderQty == 0)
{
PXTrace.WriteInformation("First Scan Detected, Setting OrderQty to 1");
existingLine.OrderQty = 1;
}
else
{
PXTrace.WriteInformation("Incrementing Quantity by 1");
existingLine.OrderQty += 1;
}
Base.Transactions.Update(existingLine);
}
else
{
// Otherwise, insert a new POLine with a default Qty = 1
PXTrace.WriteInformation("No Existing Line Found. Creating New Line.");
POLine newLine = new POLine
{
InventoryID = item.InventoryID,
OrderQty = 1,
CuryUnitCost = item.BasePrice
};
Base.Transactions.Insert(newLine);
}
// Refresh the transaction lines to show the updated quantity
Base.Transactions.View.RequestRefresh();
// Clear the Barcode field after processing
cache.SetValueExt(order, null);
Base.Document.Update(order);
cache.IsDirty = true;
}
#endregion
#region Persist Override
public delegate void PersistDelegate();
[PXOverride]
public void Persist(PersistDelegate basePersist)
{
try
{
POOrder order = Base.Document.Current;
if (order != null && order.Status == POOrderStatus.Hold)
{
Base.releaseFromHold.Press();
}
basePersist();
}
catch (PXException ex)
{
throw new PXException(ex.Message);
}
}
#endregion
}
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... tomization
ПО Акуматика настройка ⇐ C#
Место общения программистов C#
1737951289
Anonymous
Я добавил поле штрих -кода на экран PO. Функциональность работает нормально, но я сталкиваюсь с проблемой, когда всякий раз, когда я впервые сканирую продукт, OrderQty автоматически устанавливается на 2. Когда я снова сканирую тот же продукт, OrderQty увеличивается до 3, что является правильным. /p>
Но я впервые должен быть 1 не 2. Первое сканирование (вторая линия PO). Я попытался решить эту проблему, но еще не был успешным. >
Вот мой код: < /p>
using PX.Data;
using PX.Objects.PO;
using PX.Objects.IN;
using PX.Objects.CS;
using System.Linq;
namespace PX.Objects.PO
{
public class POOrderEntry_Extension : PXGraphExtension
{
#region Event Handlers
protected virtual void POOrder_UsrInventoryBarCode_FieldUpdated(
PXCache cache,
PXFieldUpdatedEventArgs e,
PXFieldUpdated BaseMethod)
{
// Call base event handler if it exists
BaseMethod?.Invoke(cache, e);
// Get the current POOrder
POOrder order = e.Row as POOrder;
if (order == null) return;
POOrderExt orderExt = cache.GetExtension(order);
if (string.IsNullOrEmpty(orderExt?.UsrInventoryBarCode))
return;
// Lookup the INItemXRef record using the scanned barcode
INItemXRef xRef = PXSelectJoin<
INItemXRef,
InnerJoin,
Where>
.Select(Base, INAlternateType.Barcode, orderExt.UsrInventoryBarCode);
if (xRef == null)
{
throw new PXSetPropertyException(
"Barcode not found in the system.");
}
// Retrieve the InventoryItem from the cross-reference
InventoryItem item = PXSelect<
InventoryItem,
Where>
.Select(Base, xRef.InventoryID);
if (item == null)
{
throw new PXSetPropertyException(
"Inventory Item not found.");
}
// Check vendor compatibility via POVendorInventory
POVendorInventory vendorItem = PXSelect<
POVendorInventory,
Where>
.Select(Base, item.InventoryID);
if (vendorItem != null)
{
if (order.VendorID == null)
{
order.VendorID = vendorItem.VendorID;
cache.RaiseFieldUpdated(order, order.VendorID);
Base.Document.Update(order);
}
else if (order.VendorID != vendorItem.VendorID)
{
throw new PXSetPropertyException(
"Scanned item belongs to a different vendor.");
}
}
// Check if a POLine for this InventoryID already exists (accumulate quantity).
var existingLine = Base.Transactions
.Select()
.RowCast()
.FirstOrDefault(l => l.InventoryID == item.InventoryID);
if (existingLine != null)
{
PXTrace.WriteInformation($"Existing Line Found: {existingLine.InventoryID}, Current Qty: {existingLine.OrderQty}");
if (existingLine.OrderQty == 0)
{
PXTrace.WriteInformation("First Scan Detected, Setting OrderQty to 1");
existingLine.OrderQty = 1;
}
else
{
PXTrace.WriteInformation("Incrementing Quantity by 1");
existingLine.OrderQty += 1;
}
Base.Transactions.Update(existingLine);
}
else
{
// Otherwise, insert a new POLine with a default Qty = 1
PXTrace.WriteInformation("No Existing Line Found. Creating New Line.");
POLine newLine = new POLine
{
InventoryID = item.InventoryID,
OrderQty = 1,
CuryUnitCost = item.BasePrice
};
Base.Transactions.Insert(newLine);
}
// Refresh the transaction lines to show the updated quantity
Base.Transactions.View.RequestRefresh();
// Clear the Barcode field after processing
cache.SetValueExt(order, null);
Base.Document.Update(order);
cache.IsDirty = true;
}
#endregion
#region Persist Override
public delegate void PersistDelegate();
[PXOverride]
public void Persist(PersistDelegate basePersist)
{
try
{
POOrder order = Base.Document.Current;
if (order != null && order.Status == POOrderStatus.Hold)
{
Base.releaseFromHold.Press();
}
basePersist();
}
catch (PXException ex)
{
throw new PXException(ex.Message);
}
}
#endregion
}
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79387632/po-acumatica-customization[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия