Creating Sales Order from Purch Order :
void clicked()
{
NumberSeq num;
SalesTable salesTable;
SalesId newSalesId;
CustTable custTable;
SalesLine salesLine;
InventTable inventTable;
;
//create sales table
salesTable.clear();
salesTable.initValue();
breakpoint;
num = NumberSeq::newGetNum(SalesParameters::numRefSalesId());
newSalesId = num.num();
if (salesTable::exist(newSalesId))
{
num.abort();
checkFailed("@LIQ1977");
checkFailed(strfmt("@LIQ1978", newSalesId));
throw error("@SYS23020");
}
salesTable.SalesId = newSalesId;
num.used();
select * from custTable where custTable.AccountNum == PurchTable.OrderAccount;
salesTable.CustAccount = custTable.AccountNum;
salesTable.InvoiceAccount = custTable.InvoiceAccount;
salesTable.SalesType = SalesType::Sales;
salesTable.SalesStatus = SalesStatus::Backorder;
salesTable.CurrencyCode = custTable.Currency;
salesTable.CustGroup = custTable.CustGroup;
salesTable.DeliveryDateControlType = SalesDeliveryDateControlType::SalesLeadTime;
salesTable.ReceiptDateRequested = PurchTable.ReceiptDateConfirmed;
salesTable.ShippingDateRequested = PurchTable.ShippingDateRequested;
salesTable.PurchOrderFormNum = "Test";
salesTable.LanguageId = "EN-US";
salesTable.DlvMode = PurchTable.DlvMode;
salesTable.initFromCustTable();
salesTable.DeliveryName = PurchTable.DeliveryName;
salesTable.DeliveryStreet = PurchTable.DeliveryStreet;
salesTable.DeliveryCity = PurchTable.DeliveryCity;
salesTable.DeliveryZipCode =PurchTable.DeliveryZipCode;
//Create Sales Order
salesTable.insert();
// Create Sales Order Line
salesLine.SalesId = salesTable.SalesId;
salesLine.initFromSalesTable(salesTable);
externalItemId = PurchLine.ItemId;
salesLine.ItemId = externalItemId;
salesLine.SalesUnit = InventTable::find(salesLine.ItemId).salesUnitId();
select * from inventTable where inventTable.ItemId == salesLine.ItemId;
salesLine.initFromInventTable(inventTable);
salesLine.InventDimId = PurchLine.inventDimId;
salesLine.SalesQty = 1;
salesLine.ConfirmedDlv = salesTable.ShippingDateConfirmed;
salesLine.lineNum = SalesLine::lastLineNum(salesLine.salesId) + 1.0;
salesLine.LinePercent = 10;
salesLine.RemainInventPhysical = 1;
salesLine.RemainSalesPhysical = 1;
salesLine.DlvMode = salesTable.DlvMode;
salesLine.SalesStatus = SalesStatus::Backorder;
salesLine.setPriceDisc(inventDim);
//Insert sales line items
salesLine.insert();
info(salesTable.SalesId);
info("Sales Order Created");
super();
}
void clicked()
{
NumberSeq num;
SalesTable salesTable;
SalesId newSalesId;
CustTable custTable;
SalesLine salesLine;
InventTable inventTable;
;
//create sales table
salesTable.clear();
salesTable.initValue();
breakpoint;
num = NumberSeq::newGetNum(SalesParameters::numRefSalesId());
newSalesId = num.num();
if (salesTable::exist(newSalesId))
{
num.abort();
checkFailed("@LIQ1977");
checkFailed(strfmt("@LIQ1978", newSalesId));
throw error("@SYS23020");
}
salesTable.SalesId = newSalesId;
num.used();
select * from custTable where custTable.AccountNum == PurchTable.OrderAccount;
salesTable.CustAccount = custTable.AccountNum;
salesTable.InvoiceAccount = custTable.InvoiceAccount;
salesTable.SalesType = SalesType::Sales;
salesTable.SalesStatus = SalesStatus::Backorder;
salesTable.CurrencyCode = custTable.Currency;
salesTable.CustGroup = custTable.CustGroup;
salesTable.DeliveryDateControlType = SalesDeliveryDateControlType::SalesLeadTime;
salesTable.ReceiptDateRequested = PurchTable.ReceiptDateConfirmed;
salesTable.ShippingDateRequested = PurchTable.ShippingDateRequested;
salesTable.PurchOrderFormNum = "Test";
salesTable.LanguageId = "EN-US";
salesTable.DlvMode = PurchTable.DlvMode;
salesTable.initFromCustTable();
salesTable.DeliveryName = PurchTable.DeliveryName;
salesTable.DeliveryStreet = PurchTable.DeliveryStreet;
salesTable.DeliveryCity = PurchTable.DeliveryCity;
salesTable.DeliveryZipCode =PurchTable.DeliveryZipCode;
//Create Sales Order
salesTable.insert();
// Create Sales Order Line
salesLine.SalesId = salesTable.SalesId;
salesLine.initFromSalesTable(salesTable);
externalItemId = PurchLine.ItemId;
salesLine.ItemId = externalItemId;
salesLine.SalesUnit = InventTable::find(salesLine.ItemId).salesUnitId();
select * from inventTable where inventTable.ItemId == salesLine.ItemId;
salesLine.initFromInventTable(inventTable);
salesLine.InventDimId = PurchLine.inventDimId;
salesLine.SalesQty = 1;
salesLine.ConfirmedDlv = salesTable.ShippingDateConfirmed;
salesLine.lineNum = SalesLine::lastLineNum(salesLine.salesId) + 1.0;
salesLine.LinePercent = 10;
salesLine.RemainInventPhysical = 1;
salesLine.RemainSalesPhysical = 1;
salesLine.DlvMode = salesTable.DlvMode;
salesLine.SalesStatus = SalesStatus::Backorder;
salesLine.setPriceDisc(inventDim);
//Insert sales line items
salesLine.insert();
info(salesTable.SalesId);
info("Sales Order Created");
super();
}