如何在 quickbooks 发票中设置发票日期?

How to set invoice date in quickbooks invoice?

我正在使用 quickbooks,我想将发票日期设置为我想要的。我正在使用这段代码。

如果我将它设置为 TxnDate 字段,它会抛出错误。那么如何设置 invStartDate?

const createInvoiceObj = {
    DocNumber: docNumber,
    Line: [
      {
        Id: "1",
        LineNum: 1,
        Description: `The description`,
        Amount: 1232,
        DetailType: "SalesItemLineDetail",
        SalesItemLineDetail: {
          ItemRef: {
            value: "19",
            name: "Service"
          },
          UnitPrice: 1232,
          Qty: "1"
        }
      }
    ],
    CustomerRef: {
      value: "1"
    },
    CustomerMemo: {
      value: "Thank you for your business and have a great day!"
    },
    TotalAmt: totalAmount,
    TxnDate: moment(order.createdAt).format("YYYY-MM-DD")  // TxnDate: '2020-05-22'
  };

我在使用 TxnDate 时遇到错误

{
  "Fault": {
    "Error": [
      {
        "Message": "Transaction date is prior to start date for inventory item",
        "Detail": "Transactions with inventory (QOH) products cant be dated earlier than the Inventory Start Date for the product",
        "code": "6270",
        "element": ""
      }
    ],
    "type": "ValidationFault"
  },
  "time": "2020-05-27T05:26:58.217-07:00"
}

设置发票日期的正确字段是TxnDate

示例:

{
  "Invoice": {
    "TxnDate": "2014-09-19", 
...

这里有很好的记录:

如果您收到此错误消息:

"Error": [
      {
        "Message": "Transaction date is prior to start date for inventory item",
        "Detail": "Transactions with inventory (QOH) products cant be dated earlier than the Inventory Start Date for the product",
        "code": "6270",
        "element": ""
      }
    ],

这意味着您发送的日期毫无意义。在真实场景中,您要做的是:

You have 0 widgets in inventory 
You try to sell 5 items (you can't, you have zero items in inventory)
You start carrying and stocking widgets in inventory 

发票日期需要您created/started携带item/product的日期之后。

更改发票日期,使发票日期在您声明item/product之后

$dateTime = new \DateTime('NOW');

$i = 1;

while (1) {
    $ccp = new IPPCreditCardPaymentTxn();
    $ccp->TxnData = $dateTime;

    $BankAccountRef = new IPPReferenceType();
    $BankAccountRef->value = "35";
    $BankAccountRef->name = "null";
    $ccp->BankAccountRef = $BankAccountRef;

    $CreditCardAccountRef = new IPPReferenceType();
    $CreditCardAccountRef->value = "41";
    $CreditCardAccountRef->name = "null";
    $ccp->CreditCardAccountRef = $CreditCardAccountRef;
    $ccp->Amount = 10;

    $result = $dataService->add($ccp);

    echo "<br> Result id is: " .$result->Id . "<br><br>";
    $error = $dataService->getLastError();

    if ($error) {
        echo "The Status: " . $error->getHttpStatusCode() . "<br><br>";
        echo "The Helper: " . $error->getOAuthHelperError() . "<br><br>";
        echo "The Response: " . $error->getResponseBody() . "<br><br>";
    } else {
        var_dump($result);
    }
    exit;
}

阅读:https://github.com/intuit/QuickBooks-V3-PHP-SDK/blob/master/src/_Samples/CreditCardPaymentCreate.php

您可以更改您需要输入的数据。