首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >zoho books自定义功能,支持deluge

zoho books自定义功能,支持deluge
EN

Stack Overflow用户
提问于 2019-03-05 11:53:37
回答 2查看 679关注 0票数 1

我在zoho图书中创建了一个自定义函数,它将使用zoho图书中的支付记录信息在zoho creator中创建一条记录。我已经能够在zoho creator中成功地创建一条记录,但是我无法从customer_payment映射中获取invoice_id。

不幸的是,没有抛出错误。

代码如下:

代码语言:javascript
复制
paymentMap = Map();

//set order to payment invoice id - this is not working
paymentMap.put("Order",customer_payment.get("invoices[0].invoice_id"));

paymentMap.put("Description",customer_payment.get("card_type"));
paymentMap.put("Payment_ZB_ID",customer_payment.get("payment_id"));
response = zoho.creator.createRecord("XXXXX","XX","Payment",paymentMap);
info response;

下面是可用的地图:

代码语言:javascript
复制
customer_payment

{

 "payment_id": "11111111111111111",

 "payment_number": "1",

 "payment_number_prefix": "",

 "payment_number_suffix": "1",

 "documents": [],

 "customer_id": "11111111111111111",

 "customer_name": "John Doe",

 "payment_mode": "Stripe",

 "card_type": "visa",

 "card_type_formatted": "Visa",

 "date": "2019-03-04",

 "date_formatted": "03/04/2019",

 "account_id": "11111111111111111",

 "account_name": "Stripe Clearing",

 "account_type": "payment_clearing",

 "account_type_formatted": "Payment Clearing Account",

 "currency_id": "11111111111111111",

 "currency_code": "USD",

 "exchange_rate": 1,

 "exchange_rate_formatted": "$1.00",

 "amount": 1,

 "amount_formatted": "$1.00",

 "unused_amount": 0,

 "unused_amount_formatted": "$0.00",

 "bank_charges": 0.33,

 "bank_charges_formatted": "$0.33",

 "tax_account_id": "",

 "is_client_review_settings_enabled": false,

 "tax_account_name": "",

 "tax_amount_withheld": 0,

 "tax_amount_withheld_formatted": "$0.00",

 "discount_amount": 0,

 "discount_amount_formatted": "$0.00",

 "description": "Stripe processing fees : $0.33 ",

 "reference_number": "12345",

 "online_transaction_id": "12345",

 "settlement_status": "",

 "settlement_status_formatted": "",

 "invoices": [

  {

   "invoice_number": "11111111111111111",

   "invoice_payment_id": "11111111111111111",

   "invoice_id": "11111111111111111",

   "amount_applied": 1,

   "amount_applied_formatted": "$1.00",

   "tax_amount_withheld": 0,

   "tax_amount_withheld_formatted": "$0.00",

   "discount_amount": 0,

   "discount_amount_formatted": "$0.00",

   "total": 1,

   "total_formatted": "$1.00",

   "balance": 0,

   "balance_formatted": "$0.00",

   "date": "2019-03-04",

   "date_formatted": "03/04/2019",

   "due_date": "2019-03-04",

   "due_date_formatted": "03/04/2019",

   "price_precision": 2,

   "apply_date": "",

   "apply_date_formatted": ""

  }

 ],

 "payment_refunds": [],

 "last_four_digits": "1234",

 "template_id": "11111111111111111",

 "template_name": "Elite Template",

 "page_width": "8.27in",

 "page_height": "11.69in",

 "orientation": "portrait",

 "template_type": "elite",

 "template_type_formatted": "Elite",

 "attachment_name": "",

 "can_send_in_mail": true,

 "can_send_payment_sms": false,

 "is_payment_details_required": true,

 "custom_fields": [],

 "custom_field_hash": {},

 "imported_transactions": []

}
EN

回答 2

Stack Overflow用户

发布于 2019-03-27 19:30:07

您可以像这样获取invoice_id:

代码语言:javascript
复制
 customer_payment = {"payment_id":"11111111111111111","payment_number":"1","payment_number_prefix":"","payment_number_suffix":"1","documents":{},"customer_id":"11111111111111111","customer_name":"John Doe","payment_mode":"Stripe","card_type":"visa","card_type_formatted":"Visa","date":"2019-03-04","date_formatted":"03/04/2019","account_id":"11111111111111111","account_name":"Stripe Clearing","account_type":"payment_clearing","account_type_formatted":"Payment Clearing Account","currency_id":"11111111111111111","currency_code":"USD","exchange_rate":1,"exchange_rate_formatted":"$1.00","amount":1,"amount_formatted":"$1.00","unused_amount":0,"unused_amount_formatted":"$0.00","bank_charges":0.33,"bank_charges_formatted":"$0.33","tax_account_id":"","is_client_review_settings_enabled":false,"tax_account_name":"","tax_amount_withheld":0,"tax_amount_withheld_formatted":"$0.00","discount_amount":0,"discount_amount_formatted":"$0.00","description":"Stripe processing fees : $0.33 ","reference_number":"12345","online_transaction_id":"12345","settlement_status":"","settlement_status_formatted":"","invoices":{{"invoice_number":"11111111111111111","invoice_payment_id":"11111111111111111","invoice_id":"11111111111111111","amount_applied":1,"amount_applied_formatted":"$1.00","tax_amount_withheld":0,"tax_amount_withheld_formatted":"$0.00","discount_amount":0,"discount_amount_formatted":"$0.00","total":1,"total_formatted":"$1.00","balance":0,"balance_formatted":"$0.00","date":"2019-03-04","date_formatted":"03/04/2019","due_date":"2019-03-04","due_date_formatted":"03/04/2019","price_precision":2,"apply_date":"","apply_date_formatted":""}},"payment_refunds":{},"last_four_digits":"1234","template_id":"11111111111111111","template_name":"Elite Template","page_width":"8.27in","page_height":"11.69in","orientation":"portrait","template_type":"elite","template_type_formatted":"Elite","attachment_name":"","can_send_in_mail":true,"can_send_payment_sms":false,"is_payment_details_required":true,"custom_fields":{},"custom_field_hash":{},"imported_transactions":{}};



    invoices = customer_payment.getJson("invoices");
    //info invoices;
    invoiceId = invoices.getJSON("invoice_id");
    info invoiceId;
票数 0
EN

Stack Overflow用户

发布于 2020-01-03 16:47:24

代码语言:javascript
复制
paymentMap.put("Order",customer_payment.get("invoices[0].invoice_id"));

Deluge在这里不会抛出错误。取而代之的是,当一个元素的键不可用时,它会抛出一个

您的代码片段invoices.invoice_id中使用的键不是customer_payment映射中的有效键。因此,这已经抛出了一个null值,它会在Zoho Creator中填充为一个空(或无)值。

如果您清楚地注意到customer_payment,那么所有发票都可以在" invoices“键下找到。

invoices = customer_payment.get(" invoices ");//现在invoices将拥有customer_payment映射中的发票列表

假设支付只有一张发票,则可以提取发票ID如下:

代码语言:javascript
复制
invoiceId = invoices.getJson("invoice_id");

也可以像您尝试的那样提取发票ID,如下所示:

代码语言:javascript
复制
info customer_payment.get("invoices").get(0).get("invoice_id");
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54995158

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档