Prudent Documentation

Prudent Documentation

  • Blog
  • Reference

›Developers

Getting Started

  • What is Prudent?
  • Installing Prudent
  • Overview
  • Opening balances
  • Next steps

Mobile apps

  • Prudent Expenses iOS

Guides

  • Journals
  • Currencies and Commodities
  • Base Currency
  • Price movements
  • Accounts
  • Transactions
  • Calendar
  • Import transactions
  • Import auto-suggest
  • Import memory
  • Dealing with stocks
  • Dealing with properties

Use cases

  • Combining Journals
  • Navigating Accounts
  • Tracking Reconciliation

Extensions

  • OCBC CSV
  • UOB XLS
  • CPF PDF
  • CPF Tabula
  • QIF
  • SG Property Price
  • Standard Chartered CSV
  • DBS/POSB CSV
  • Public Bank CSV
  • Interest
  • Reconciliation
  • Expenses vs Envelope budgeting
  • All extensions

Developers

  • Creating extensions
  • Local Extensions
  • Sharing extensions
  • Creating update extensions
  • Extension creation helpers

Coverage

  • Singapore
  • Banks

Useful

  • Prudent and Ledger
  • Samples

Creating update extensions

Update extensions are used to update commodity prices in Prudent. It is quite similar to import extensions in terms of structure with the exception of four differences:

  1. @require/update-addon

  2. start()'s processing function receives params instead of content

  3. start() expects a second , example object. Look out for this snippet in the example below:

{
   epoch: '2012-Q3',
   basePrice : 1000
}
  1. Use price in the protocol instead of transactions

Example

Here's an example of an update extension with the above 4 points met:

let encode = require('@prudent/encode');

require('@prudent/update-addon').start(function(params) {    
    let epoch = params.epoch;
    let basePrice = params.basePrice;

    // Do somethign with the params, i.e. call an external service 
    // and/or do some maths, and when ready:

    console.log(encode.protocol('price', currentPrice));
}, {
   epoch: '2012-Q3',
   basePrice : 1000
});

When Prudent communicates with this extension, it'll first ask for an example of parameters that this extension expects, which is again this part here:

{
   epoch: '2012-Q3',
   basePrice : 1000
}

When this is known, Prudent will then send params filled with either the same example value (if there'd been no changes from the user) or different values to the processing function. This should be used within the processing function for update specific variables. When ready, do:

console.log(encode.protocol('price', currentPrice));

id: creating_update_ext title: Creating update extensions


Update extensions are used to update commodity prices in Prudent. It is quite similar to import extensions in terms of structure with the exception of four differences:

  1. @require/update-addon

  2. start()'s processing function receives params instead of content

  3. start() expects a second , example object. Look out for this snippet in the example below:

{
   epoch: '2012-Q3',
   basePrice : 1000,
   pricedIn: '$',
   symbol: 'ORP'
}
  1. Use price in the protocol instead of transactions

Example

Here's an example of an update extension with the above 4 points met:

let encode = require('@prudent/encode');

require('@prudent/update-addon').start(function(params) {    
    let epoch = params.epoch;
    let basePrice = params.basePrice;

    // Do somethign with the params, i.e. call an external service 
    // and/or do some maths, and when ready:

    console.log(encode.protocol('price', currentPrice));
}, {
   epoch: '2012-Q3',
   basePrice : 1000,
   pricedIn: '$',
   symbol: 'ORP'      
});

When Prudent communicates with this extension, it'll first ask for an example of parameters that this extension expects, which is again this part here:

{
   epoch: '2012-Q3',
   basePrice : 1000,
   pricedIn: '$',
   symbol: 'ORP'   
}

pricedIn and symbol in the above object are mandatory parameters for commodity price update addons. pricedIn indicates the commodity in which the commodity-to-be-updated is priced in, i.e. $. Symbol denotes the commodity to be updated.

When this is known, Prudent will then send params filled with either the same example value (if there'd been no changes from the user) or different values to the processing function. This should be used within the processing function for update specific variables. When ready, do:

console.log(encode.protocol('price', currentPrice));

That's all!

← Sharing extensionsExtension creation helpers →
  • Example
  • Example
Prudent Documentation
Docs
Getting StartedCurrencies and Commodities
Community
Join our mailing listTwitter
More
GitHubTerms and ConditionsAcknowledgements