0

我是 X++ 开发的新手,我想在销售订单行而不是销售订单标题中插入运费。我使用了 SalesOrderLineChargeEntity 但它没有保存记录而是抛出错误。

private void addCharges()
{
    SalesOrderLineChargeV2Entity chargeEntity;

    boolean isNew;
    str saleschargecode = 'Freight';
    str saleschargecodedesc = 'Freight Charges';

    if(saleschargecode != '')
    {
        select forupdate chargeEntity  where chargeEntity.SalesOrderNumber=='22676' && chargeEntity.SalesChargeCode == saleschargecode && chargeEntity.ChargeLineNumber == 1;

        if(!chargeEntity)
        {
            isNew = true;
            chargeEntity.clear();
        }
        chargeEntity.ChargeCategory = MarkupCategory::Fixed;
        chargeEntity.SalesChargeCode = saleschargecode;
        chargeEntity.ChargeDescription=saleschargecodedesc;
        chargeEntity.ChargeAccountingCurrencyCode = _ecomIntSalesOrderImportStaging.currency_id;
        chargeEntity.ChargePercentage=0;
        chargeEntity.ExternalChargeAmount=0;
        chargeEntity.FixedChargeAmount= 230;
        chargeEntity.ChargeLineNumber=1;


        chargeEntity.SalesOrderNumber='22676';

        chargeEntity.SalesTaxGroupCode='AvaTax';
        chargeEntity.WillInvoiceProcessingKeepCharge=NoYes::No;
        chargeEntity.IsIntercompanyCharge = NoYes::No;

        if(isNew)
        chargeEntity.insert();
        else
        chargeEntity.update();
    }
}

这是我用于插入销售线运费的代码,但它会在图片中提及错误。 在此处输入图像描述

需要帮忙。

谢谢,桑迪

4

1 回答 1

0

我可以通过分配要显示运费的销售线的 InventoryLotId 来解决问题,我做了以下代码更改:

select firstonly salesOrderLine
                where salesOrderLine.SalesOrderNumber == '22676';
chargeEntity.SalesOrderLineInventoryLotId = salesOrderLine.InventoryLotId;
于 2020-02-11T13:27:31.150 回答