无法使用资产 API 设置折旧开始日期

问题描述 投票:0回答:1

我正在尝试使用 API(而不是任何特定的 SDK)在 Xero 中创建固定资产。 除了折旧开始日期之外的所有内容似乎都正常工作。

我发送到 Xero API 的请求正文:

{
      assetName: 'Asset name',
      assetNumber: 'CA-46987', 
      serialNumber: '',
      purchasePrice: 432,
      purchaseDate: '2024-03-06T15:04:30.373',
      bookDepreciationSetting: {
        depreciationMethod: "StraightLine",
        averagingMethod: "FullMonth",
        effectiveLifeYears: 5,
        depreciationCalculationMethod: "Life"
      },
      bookDepreciationDetail: {
        depreciationStartDate: '2024-03-07'
      }
    };

我从 Xero 得到的回复如下所示:

{
...
  bookDepreciationSetting: {
    depreciableObjectId: '0965dc9e-3a5a-46f0-aac9-d7b7f0a466a5',
    depreciableObjectType: 'Asset',
    bookEffectiveDateOfChangeId: '98108fe1-9eaa-4145-b660-4f36ca2a5418',
    depreciationMethod: 'StraightLine',
    averagingMethod: 'FullMonth',
    effectiveLifeYears: 5,
    depreciationCalculationMethod: 'None'
  },
  bookDepreciationDetail: {
    depreciationStartDate: '2024-03-07T00:00:00',
    priorAccumDepreciationAmount: 0,
    currentAccumDepreciationAmount: 0,
    currentCapitalGain: 0,
    currentGainLoss: 0
  },
  taxDepreciationSettings: [],
  taxDepreciationDetails: [],
  canRollback: true,
  accountingBookValue: 432,
  taxValues: [],
  isDeleteEnabledForDate: true
}

如您所见,它响应时将 depreciationStartDate 正确设置为“2024-03-07T00:00:00”。请注意,我只发送日期部分(“2024-03-07”),因此此响应表明这不是简单的回显并且日期已被处理。

尽管如此,当我通过 Xero UI 检查新创建的固定资产时,折旧开始日期为空。所有其他信息都已正确填写。这是一个错误,还是我丢失了一些数据?

我尝试过使用日期格式:

  • '2024-03-07'
  • '2024-03-07T00:00:00'
  • '2024-03-07T00:00:00.000'
  • 完整的 ISO 日期 都没有效果。
assets xero-api
1个回答
0
投票

据我所知,由于其 .NET 框架,Xero 文档明确指出在处理 JSON 时使用 Unix 纪元格式化日期和时间戳。

因此,为了使您的请求生效,您需要将日期或

'2024-03-07'
转换为以下其中一项:

纪元时间戳(UTC):

"\/Date(1709769600)\/"

纪元时间戳(以毫秒为单位):

"\/Date(1709769600000+0000)\/"

© www.soinside.com 2019 - 2024. All rights reserved.