{% load ifsetting %}

How much has been committed?

{parent.validations.value.message}

{parent.validations.value_date.message}

Where is the money coming from?

Where is the money going to?

var tag = this; tag.mixin('TransactionModalMixin') {% ifsetting OIPA_SYNC_ENABLED %} tag.iati_block_saving = (data.iati_data.link_info.oipa_fields.indexOf("C") != -1); {% else %} tag.iati_block_saving = false; {% endifsetting %} tag.validationFunctions = { value: function validateValue(value, field){ var validated = _.isNumber(_.toNumber(value)) && !_.isNaN(_.toNumber(value)) if (validated) { tag.trigger('unSetValidation', field); $('#currency-value-select-commitment').removeClass('has-error'); } else { tag.trigger('setValidation', field, 'warning', 'Value is not a number'); $('#currency-value-select-commitment').addClass('has-error'); $('.has-warning').addClass('has-error'); $('.has-warning').addClass('validation-error'); } }, value_date: function(value, field){ var validated = moment(value).isValid() if (validated) { tag.trigger('unSetValidation', field); $('#transactions-date-picker-commitment').removeClass('has-error'); } else { tag.trigger('setValidation', field, 'warning', 'Valid date required'); $('#transactions-date-picker-commitment').addClass('has-error'); $('.has-warning').addClass('has-error'); $('.has-warning').addClass('validation-error'); } } }

How much money?

{parent.validations.value.message}

{parent.validations.value_date.message}

Where is the money coming from?

Where is the money going to?

And from which activity?

var tag = this; this.mixin('TransactionModalMixin') {% ifsetting OIPA_SYNC_ENABLED %} tag.iati_block_saving = (data.iati_data.link_info.oipa_fields.indexOf("IF") != -1); {% else %} tag.iati_block_saving = false; {% endifsetting %} tag.validationFunctions = { value: function validateValue(value, field){ var validated = _.isNumber(_.toNumber(value)) && !_.isNaN(_.toNumber(value)) if (validated) { tag.trigger('unSetValidation', field); $('#currency-value-select-incoming').removeClass('has-error'); } else { tag.trigger('setValidation', field, 'warning', 'Value is not a number'); $('#currency-value-select-incoming').addClass('has-error'); $('.has-warning').addClass('has-error'); $('.has-warning').addClass('validation-error'); } }, value_date: function(value, field){ var validated = moment(value).isValid() if (validated) { tag.trigger('unSetValidation', field); $('#transactions-date-picker-incoming').removeClass('has-error'); } else { tag.trigger('setValidation', field, 'warning', 'Valid date required'); $('#transactions-date-picker-incoming').addClass('has-error'); $('.has-warning').addClass('has-error'); $('.has-warning').addClass('validation-error'); } } }

What type of transaction is it?

How much money?

{parent.validations.value.message}

{parent.validations.value_date.message}

Where is the money coming from?

Where is the money going to?

And for what purpose?

this.mixin('TransactionModalMixin') var tag = this; {% ifsetting OIPA_SYNC_ENABLED %} tag.iati_block_saving = (data.iati_data.link_info.oipa_fields.indexOf("OF") != -1); {% else %} tag.iati_block_saving = false; {% endifsetting %} tag.setDisbursement = function(){ tag.values.transaction_type = 'D'; tag.update(); } tag.setExpenditure = function(){ tag.values.transaction_type = 'E'; tag.update(); } tag.validationFunctions = { value: function validateValue(value, field){ var validated = _.isNumber(_.toNumber(value)) && !_.isNaN(_.toNumber(value)) if (validated) { tag.trigger('unSetValidation', field); $('#currency-value-select-transaction').removeClass('has-error'); } else { tag.trigger('setValidation', field, 'warning', 'Value is not a number'); $('#currency-value-select-transaction').addClass('has-error'); $('.has-warning').addClass('has-error'); $('.has-warning').addClass('validation-error'); } }, value_date: function(value, field){ var validated = moment(value).isValid() if (validated) { tag.trigger('unSetValidation', field); $('#transactions-date-picker-transaction').removeClass('has-error'); } else { tag.trigger('setValidation', field, 'warning', 'Valid date required'); $('#transactions-date-picker-transaction').addClass('has-error'); $('.has-warning').addClass('has-error'); $('.has-warning').addClass('validation-error'); } } } tag.on('update', function(){ if (!tag.values.transaction_type) {tag.setDisbursement();} })
var tag = this; var store = stores.transactionStore; function parent(event){return _.invoke(tag.parent, event, tag)} tag.toggle = function(){parent('toggle')} tag.hide = function(){parent('hide')} tag.save = function(){ if (this.parent.values.value) { $('#currency-value-select-commitment').removeClass('has-error'); $('#currency-value-select-incoming').removeClass('has-error'); $('#currency-value-select-transaction').removeClass('has-error'); parent('save') } else { $('#currency-value-select-commitment').addClass('has-error'); $('#currency-value-select-incoming').addClass('has-error'); $('#currency-value-select-transaction').addClass('has-error'); $('.has-warning').addClass('has-error'); $('.has-warning').addClass('validation-error'); this.parent.trigger('setValidation', 'value', 'error', 'Amount value is not a set!') } } /* For dropdown-select inclusions in yielded modal-content, passes the event and the data to the parent tag */ tag.on('setdropdown', function(event, data, child_tag){ tag.parent.trigger('setdropdown', event, data, child_tag) }) /* Pass through any "set" events triggered */ this.on('set', function set(field, amount){tag.parent.trigger('set', field, amount)}) this.on('setCurrency', function(currency){this.trigger('set', 'currency', currency)}) this.on('setAmount', function(amount){this.trigger('set', 'value', amount)}) /* saved as 'value' in db, displayed as 'amount' */ tag.on('before-mount', function(){tag.toggleExtraFieldsOn = false}); tag.toggleExtraFields = function(){tag.update({toggleExtraFieldsOn: !tag.toggleExtraFieldsOn})} tag.on('update', function set_default_settings(){ var get_choice = store.get_choice; var values = tag.parent.values; var choices = ["aid_type", "finance_type", "flow_type", "tied_status"] var default_settings = _.map(choices, function(choice){ return get_choice(choice, _.get(values,choice)) }) tag.default_settings = _.join(_.compact(default_settings), ', ') }) {% comment %} Transaction Date Picker sends a "set" trigger to its parent when its value is changed to set the 'transaction_date' and 'value_date' fields of its thingamagig {% endcomment %} Date var tag = this; tag.setDate = function(e){ tag.parent.trigger('set', 'transaction_date', e.target.value); tag.parent.trigger('set', 'value_date', e.target.value); } tag.on('mount', function () { tag.datepicker_opts = $.extend({ orientation: 'top left', startView: 1, autoclose: true, format: 'yyyy-mm-dd', clearBtn: false, endDate:'0d' }, tag.opts.datepicker_opts); tag.datepicker = $('input.form-control', tag.root).datepicker(tag.datepicker_opts); tag.datepicker.on('changeDate', function () { var date = $(this).datepicker('getUTCDate'); var iso_date = moment(date).format('YYYY-MM-DD'); tag.setDate({target:{value:iso_date}}) tag.update(); }); });