| 1 | [ |
| 2 | "autonomous agent", |
| 3 | { |
| 4 | "init": "{ |
| 5 | $nom_AA = 'Portal'; |
| 6 | $versio = '0.1.2'; |
| 7 | |
| 8 | $_AUT_000 = 'C4KIJSUWVM7BGWTLXKX3K4PNRXV7OY4W'; |
| 9 | |
| 10 | |
| 11 | $adr__ = trigger.address; |
| 12 | $args = trigger.data; |
| 13 | $_unitat = trigger.output[[ asset != base ]].asset; |
| 14 | $qt = trigger.output[[ asset = $_unitat ]]; |
| 15 | |
| 16 | $dades = var[ 'dades' ] otherwise {}; |
| 17 | |
| 18 | $generics = $dades.generics otherwise {}; |
| 19 | $propostes = $dades.propostes otherwise {}; |
| 20 | $assignacions = $dades.assignacions otherwise {}; |
| 21 | $conversions = $dades.conversions otherwise {}; |
| 22 | $retribucions = $dades.retribucions otherwise {}; |
| 23 | $entitats = $dades.entitats otherwise {}; |
| 24 | |
| 25 | $_estels = $generics._Estels; |
| 26 | $getons = |
| 27 | $generics._Getons ? |
| 28 | var[ $generics._Getons ][ 'getons' ] : |
| 29 | {}; |
| 30 | $dades_accions = |
| 31 | $generics._Accions ? |
| 32 | var[ $generics._Accions ]: |
| 33 | {}; |
| 34 | $cicle_actual = $dades_accions.basiques.cicle_actual; |
| 35 | $escala_actual = $dades_accions.basiques.escala_actual; |
| 36 | |
| 37 | |
| 38 | |
| 39 | $admin = $args.admin; |
| 40 | $proces = $args.proces; |
| 41 | $ref = $args.ref; |
| 42 | $val = $args.val; |
| 43 | $idprop = $args.idprop; |
| 44 | $idgeto = $args.id_geto; |
| 45 | |
| 46 | |
| 47 | |
| 48 | $_actuant_es_AUT_000 = $adr__ == $_AUT_000; |
| 49 | |
| 50 | $_actuant_es_AUT = |
| 51 | ( $generics._AUT_A AND $generics._AUT_A == $adr__ ) |
| 52 | OR ( $generics._AUT_B AND $generics._AUT_B == $adr__ ) |
| 53 | OR ( $generics._AUT_C AND $generics._AUT_C == $adr__ ) |
| 54 | OR ( $generics._AUT_0 AND $adr__ == $generics._AUT_0 ) |
| 55 | OR ( $_actuant_es_AUT_000 AND ! is_valid_address( $generics._AUT_0 ) ); |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | $__arg = $arg => |
| 61 | $args[ $arg ] otherwise |
| 62 | bounce( "Cal proporcionar el valor de: " || $arg ); |
| 63 | |
| 64 | $__ordinal = $rf => $dades.ordinals[ $rf ] ? $dades.ordinals[ $rf ] + 1 : 1; |
| 65 | |
| 66 | |
| 67 | |
| 68 | if ( $admin ) { |
| 69 | |
| 70 | |
| 71 | if ( $args.admin_geto ) { |
| 72 | $geto = $getons[ $idgeto ]; |
| 73 | |
| 74 | |
| 75 | if ( ! $geto OR $geto.estat != 'actiu' ) |
| 76 | { bounce( 'Getó inexistent o inactiu' ); } |
| 77 | |
| 78 | |
| 79 | $varsgeto = $geto.variables; |
| 80 | $_actuant_es_AUT_geto = |
| 81 | $_actuant_es_AUT AND ! $varsgeto._AUT_0 |
| 82 | OR $adr__ == $geto.constants._AUT_A |
| 83 | OR ( $varsgeto._AUT_0 AND $adr__ == $varsgeto._AUT_0 ) |
| 84 | OR ( $varsgeto._AUT_B AND $adr__ == $varsgeto._AUT_B ) |
| 85 | OR ( $varsgeto._AUT_C AND $adr__ == $varsgeto._AUT_C ); |
| 86 | |
| 87 | if ( ! $_actuant_es_AUT_geto ) |
| 88 | { bounce( 'No autoritzada' ); } |
| 89 | |
| 90 | } else { |
| 91 | |
| 92 | if ( ! $_actuant_es_AUT ) |
| 93 | { bounce( 'No autoritzada' ); } |
| 94 | |
| 95 | |
| 96 | if ( ( $__arg( 'ref' ) ) == 'multiple' AND ! $_actuant_es_AUT_000 ) |
| 97 | { bounce( 'No autoritzada per a esmena múltiple' ); } |
| 98 | } |
| 99 | |
| 100 | |
| 101 | $validacio_requerida = |
| 102 | |
| 103 | ! $_actuant_es_AUT_000 OR ( $_actuant_es_AUT_000 AND $generics._AUT_0 ) |
| 104 | |
| 105 | AND $proces != 'decisio_validacio' |
| 106 | AND $proces != 'generacio_getons'; |
| 107 | |
| 108 | if ( $validacio_requerida ) { |
| 109 | if ( $args.operacio AND $args.operacio == 'confirmacio' ) { |
| 110 | $proposta = $propostes[ $idprop ]; |
| 111 | |
| 112 | |
| 113 | if ( ! $proposta ) |
| 114 | { bounce( "No hi ha cap proposta amb aquesta ref" ); } |
| 115 | |
| 116 | |
| 117 | if ( $proposta.proposant == $adr__ ) |
| 118 | { bounce( "El procés de confirmació l'ha d'endegar una altra AUT" ); } |
| 119 | |
| 120 | |
| 121 | if ( $generics.Lapse > timestamp - $proposta.temps ) |
| 122 | { bounce( "Encara no es pot confirmar la proposta" ); } |
| 123 | |
| 124 | |
| 125 | $dades_validacions = var[ $generics._Validacions ][ 'dades' ]; |
| 126 | if ( ! $dades_validacions.validacions[ $idprop ] ) |
| 127 | { bounce( "La proposta encara no ha estat validada" ); } |
| 128 | |
| 129 | $operacio = 'confirmacio'; |
| 130 | |
| 131 | } else { |
| 132 | $__nova_proposta = $dades_prop => { |
| 133 | $dades.ordinals[ $proces ] = $__ordinal( $proces ); |
| 134 | $nova_idprop = $proces || '_' || $dades.ordinals[ $proces ]; |
| 135 | $dades.propostes[ $nova_idprop ] = $dades_prop; |
| 136 | $nova_idprop |
| 137 | }; |
| 138 | |
| 139 | $__data_confirmacio = () => timestamp_to_string( timestamp + $generics.Lapse ); |
| 140 | |
| 141 | $operacio = 'proposta'; |
| 142 | } |
| 143 | } else { |
| 144 | $operacio = 'drecera'; |
| 145 | } |
| 146 | } |
| 147 | }", |
| 148 | "messages": { |
| 149 | "cases": [ |
| 150 | { |
| 151 | "if": "{ $proces == 'acces_accions' }", |
| 152 | "init": "{ |
| 153 | $unitat_es_geto = $getons[ $_unitat ]; |
| 154 | if ( $_unitat != $_estels |
| 155 | AND ( ! $unitat_es_geto OR $unitat_es_geto.estat != 'actiu' ) ) |
| 156 | { bounce( 'Getó inexistent o inactiu' ); } |
| 157 | }", |
| 158 | "messages": [ |
| 159 | { |
| 160 | "app": "data", |
| 161 | "payload": "{ $args }" |
| 162 | }, |
| 163 | { |
| 164 | "app": "payment", |
| 165 | "payload": { |
| 166 | "asset": "{ $_unitat }", |
| 167 | "outputs": [ |
| 168 | { |
| 169 | "address": "{ $generics._Accions }", |
| 170 | "amount": "{ $qt }" |
| 171 | } |
| 172 | ] |
| 173 | } |
| 174 | } |
| 175 | ] |
| 176 | }, |
| 177 | { |
| 178 | "if": "{ $admin AND $proces == 'renovacio_adrs_portal' }", |
| 179 | "init": "{ |
| 180 | $args.nou_portal = |
| 181 | $operacio == 'proposta' ? |
| 182 | false : true; |
| 183 | }", |
| 184 | "messages": [ |
| 185 | { |
| 186 | "app": "data", |
| 187 | "payload": "{ $args }" |
| 188 | }, |
| 189 | { |
| 190 | "app": "payment", |
| 191 | "payload": { |
| 192 | "asset": "{ $_unitat }", |
| 193 | "outputs": [ |
| 194 | { |
| 195 | "address": "{ $generics._Accions }", |
| 196 | "amount": "{ $qt }" |
| 197 | } |
| 198 | ] |
| 199 | } |
| 200 | }, |
| 201 | { |
| 202 | "app": "data", |
| 203 | "payload": "{ $args }" |
| 204 | }, |
| 205 | { |
| 206 | "app": "payment", |
| 207 | "payload": { |
| 208 | "asset": "{ $_unitat }", |
| 209 | "outputs": [ |
| 210 | { |
| 211 | "address": "{ $generics._Getons }", |
| 212 | "amount": "{ $qt }" |
| 213 | } |
| 214 | ] |
| 215 | } |
| 216 | }, |
| 217 | { |
| 218 | "app": "data", |
| 219 | "payload": "{ $args }" |
| 220 | }, |
| 221 | { |
| 222 | "app": "payment", |
| 223 | "payload": { |
| 224 | "asset": "{ $_unitat }", |
| 225 | "outputs": [ |
| 226 | { |
| 227 | "address": "{ $generics._Validadores }", |
| 228 | "amount": "{ $qt }" |
| 229 | } |
| 230 | ] |
| 231 | } |
| 232 | }, |
| 233 | { |
| 234 | "app": "data", |
| 235 | "payload": "{ $args }" |
| 236 | }, |
| 237 | { |
| 238 | "app": "payment", |
| 239 | "payload": { |
| 240 | "asset": "{ $_unitat }", |
| 241 | "outputs": [ |
| 242 | { |
| 243 | "address": "{ $generics._Validacions }", |
| 244 | "amount": "{ $qt }" |
| 245 | } |
| 246 | ] |
| 247 | } |
| 248 | } |
| 249 | ] |
| 250 | }, |
| 251 | { |
| 252 | "if": "{ $admin AND $proces == 'copia_dades_portal' }", |
| 253 | "messages": [ |
| 254 | { |
| 255 | "app": "state", |
| 256 | "state": "{ |
| 257 | $refs_dades = [ |
| 258 | 'generics', 'propostes', 'ordinals', 'assignacions', |
| 259 | 'conversions', 'retribucions', 'entitats' |
| 260 | ]; |
| 261 | |
| 262 | $dades_portal_actual = var[ $__arg( 'val' )][ 'dades' ]; |
| 263 | $renovacions = $dades_portal_actual[ 'renovacions' ] otherwise []; |
| 264 | $noves_dades = {}; |
| 265 | |
| 266 | $__copia_dades = $ref_dades => { |
| 267 | $noves_dades[ $ref_dades ] = |
| 268 | $dades_portal_actual[ $ref_dades ] |
| 269 | otherwise []; |
| 270 | }; |
| 271 | |
| 272 | $copia = map( $refs_dades, 7, $__copia_dades ); |
| 273 | |
| 274 | if ( $operacio == 'proposta' ) { |
| 275 | $dades_proposta = |
| 276 | { |
| 277 | dades: $noves_dades, |
| 278 | proposant: $adr__, |
| 279 | temps: timestamp, |
| 280 | }; |
| 281 | response[ 'proposta' ] = $__nova_proposta( $dades_proposta ); |
| 282 | } else { |
| 283 | $__valvar = $refvar => { |
| 284 | $dades[ $refvar ] = |
| 285 | $proposta.dades[ $refvar ] |
| 286 | otherwise $noves_dades[ $refvar ]; |
| 287 | }; |
| 288 | |
| 289 | $seleccio = map( $refs_dades, 7, $__valvar ); |
| 290 | |
| 291 | $dades.renovacions[] = $val; |
| 292 | $dades.darrer_portal = $val; |
| 293 | |
| 294 | response[ 'darrer_portal' ] = $val; |
| 295 | response[ 'nombre renovacions' ] = array_length( $renovacions ) + 1; |
| 296 | |
| 297 | if ( $idprop ) { response[ 'proposta' ] = $idprop; } |
| 298 | response[ 'procés' ] = $proces; |
| 299 | var[ 'dades' ] = $dades; |
| 300 | } |
| 301 | }" |
| 302 | } |
| 303 | ] |
| 304 | }, |
| 305 | { |
| 306 | "if": "{ $admin AND $proces == 'copia_dades' }", |
| 307 | "init": "{ |
| 308 | $args.copia_dades = |
| 309 | $operacio == 'proposta' ? false : true; |
| 310 | $args.adr_aa = $generics[ '_' || $args.nom_aa ]; |
| 311 | }", |
| 312 | "messages": [ |
| 313 | { |
| 314 | "app": "data", |
| 315 | "payload": "{ $args }" |
| 316 | }, |
| 317 | { |
| 318 | "if": "{ $operacio != 'proposta' }", |
| 319 | "app": "payment", |
| 320 | "payload": { |
| 321 | "asset": "{ $_unitat }", |
| 322 | "outputs": [ |
| 323 | { |
| 324 | "address": "{ $args.adr_aa }", |
| 325 | "amount": "{ $qt }" |
| 326 | } |
| 327 | ] |
| 328 | } |
| 329 | }, |
| 330 | { |
| 331 | "app": "state", |
| 332 | "state": "{ |
| 333 | if ( $operacio == 'proposta' ) { |
| 334 | $dades_proposta = |
| 335 | { |
| 336 | nom_aa: $args.nom_aa, |
| 337 | proposant: $adr__, |
| 338 | temps: timestamp, |
| 339 | }; |
| 340 | response[ 'proposta' ] = $__nova_proposta( $dades_proposta ); |
| 341 | } |
| 342 | response[ 'procés' ] = $proces; |
| 343 | }" |
| 344 | } |
| 345 | ] |
| 346 | }, |
| 347 | { |
| 348 | "if": "{ $admin AND $proces == 'esmena_generics' }", |
| 349 | "messages": [ |
| 350 | { |
| 351 | "app": "state", |
| 352 | "state": "{ |
| 353 | if ( ! $generics AND $ref != 'multiple' ) |
| 354 | { bounce( "No hi ha generics" ); } |
| 355 | |
| 356 | if ( $operacio == 'drecera' ) { |
| 357 | if ( $ref == 'multiple' ) { |
| 358 | |
| 359 | $__resp = $r => { |
| 360 | $valvar = |
| 361 | $args[ $r ] otherwise $generics[ $r ] otherwise '...'; |
| 362 | $generics[ $r ] = $valvar; |
| 363 | response[ $r ] = $valvar; |
| 364 | }; |
| 365 | |
| 366 | $refs_generics = [ |
| 367 | '_Accions', '_Getons', '_Validacions', '_Validadores', |
| 368 | '_FRO', '_Estels', 'Interval', 'Lapse', |
| 369 | 'Import_Activacio', 'Import_Subscripcio', 'Import_Renovacio', |
| 370 | 'Taxa_Conversio', 'Factor_Conversio', 'Generacio_Minima', |
| 371 | 'Nombre_Delegades', 'Nombre_Aprovacions', 'Cicles_Diposit', |
| 372 | '_AUT_A', '_AUT_B', '_AUT_C' |
| 373 | ]; |
| 374 | |
| 375 | $generics_AUT_0 = ''; |
| 376 | |
| 377 | $valora = map( $refs_generics, 21, $__resp ); |
| 378 | |
| 379 | } else { |
| 380 | $generics[ $__arg( 'ref' ) ] = $__arg( 'val' ); |
| 381 | $nova_ref = $ref; |
| 382 | $nou_val = $val; |
| 383 | } |
| 384 | } else if ( $operacio == 'confirmacio' ) { |
| 385 | $generics[ $proposta.ref ] = $proposta.val; |
| 386 | $nova_ref = $proposta.ref; |
| 387 | $nou_val = $proposta.val; |
| 388 | response[ 'proposta' ] = $idprop; |
| 389 | } else { |
| 390 | $dades_proposta = |
| 391 | { |
| 392 | ref: $__arg( 'ref' ), |
| 393 | val: $__arg( 'val' ), |
| 394 | proposant: $adr__, |
| 395 | temps: timestamp, |
| 396 | }; |
| 397 | response[ 'proposta' ] = $__nova_proposta( $dades_proposta ); |
| 398 | $nova_ref = $ref; |
| 399 | $nou_val = $val; |
| 400 | } |
| 401 | if( $nova_ref ) { |
| 402 | response[ 'ref' ] = $nova_ref; |
| 403 | response[ 'nou valor' ] = $nou_val; |
| 404 | } |
| 405 | $dades.generics = $generics; |
| 406 | var[ 'dades' ] = $dades; |
| 407 | response[ 'procés' ] = $proces; |
| 408 | }" |
| 409 | } |
| 410 | ] |
| 411 | }, |
| 412 | { |
| 413 | "if": "{ $args.admin_geto }", |
| 414 | "init": "{ |
| 415 | $args.operacio = $operacio; |
| 416 | $args.proposta = $proposta; |
| 417 | }", |
| 418 | "messages": [ |
| 419 | { |
| 420 | "if": "{ $proces == 'nou_geto' AND $operacio != 'proposta' }", |
| 421 | "app": "asset", |
| 422 | "payload": { |
| 423 | "cap": "{ $args.cap otherwise 1e9 }", |
| 424 | "is_private": false, |
| 425 | "is_transferrable": true, |
| 426 | "auto_destroy": "{ !! $args.auto_destroy }", |
| 427 | "fixed_denominations": false, |
| 428 | "issued_by_definer_only": true, |
| 429 | "cosigned_by_definer": false, |
| 430 | "spender_attested": false |
| 431 | } |
| 432 | }, |
| 433 | { |
| 434 | "if": "{ $proces == 'generacio_getons' AND $operacio != 'proposta' }", |
| 435 | "init": "{ |
| 436 | if ( $_unitat != $_estels ) |
| 437 | { bounce( 'Cal aportar-hi estels' ); } |
| 438 | |
| 439 | if ( $qt < $generics.Generacio_Minima ) |
| 440 | { bounce( 'Cal aportar-hi si més no ' |
| 441 | || $generics.Generacio_Minima || ' estels' ); } |
| 442 | }", |
| 443 | "app": "payment", |
| 444 | "payload": { |
| 445 | "asset": "{ $idgeto }", |
| 446 | "outputs": [ |
| 447 | { |
| 448 | "address": "{ $getons.constants._FOP }", |
| 449 | "amount": "{ $qt * $getons.constants.factor_conversio }" |
| 450 | } |
| 451 | ] |
| 452 | } |
| 453 | }, |
| 454 | { |
| 455 | "app": "data", |
| 456 | "payload": "{ $args }" |
| 457 | }, |
| 458 | { |
| 459 | "app": "payment", |
| 460 | "payload": { |
| 461 | "asset": "{ $_unitat }", |
| 462 | "outputs": [ |
| 463 | { |
| 464 | "address": "{ $generics._Getons }", |
| 465 | "amount": "{ $qt }" |
| 466 | } |
| 467 | ] |
| 468 | } |
| 469 | } |
| 470 | ] |
| 471 | }, |
| 472 | { |
| 473 | "if": "{ $admin AND $proces == 'assignacio' }", |
| 474 | "init": "{ |
| 475 | $unitat = $proposta.unitat otherwise $args.unitat; |
| 476 | $qt_assignacio = $proposta.qt otherwise $args.qt; |
| 477 | $receptora = $proposta.receptora otherwise $args.receptora; |
| 478 | }", |
| 479 | "messages": [ |
| 480 | { |
| 481 | "if": "{ $operacio != 'proposta' }", |
| 482 | "app": "payment", |
| 483 | "payload": { |
| 484 | "asset": "{ $unitat }", |
| 485 | "outputs": [ |
| 486 | { |
| 487 | "address": "{ $receptora }", |
| 488 | "amount": "{ $qt_assignacio }" |
| 489 | } |
| 490 | ] |
| 491 | } |
| 492 | }, |
| 493 | { |
| 494 | "app": "state", |
| 495 | "state": "{ |
| 496 | if ( $operacio == 'proposta' ) { |
| 497 | $dades_proposta = |
| 498 | { |
| 499 | proposant: $adr__, |
| 500 | temps: timestamp, |
| 501 | resolucio: $args.resolucio, |
| 502 | requeriment: $args.requeriment, |
| 503 | qt: $args.qt, |
| 504 | receptora: $args.receptora, |
| 505 | unitat: $args.unitat |
| 506 | }; |
| 507 | response[ 'proposta' ] = $__nova_proposta( $dades_proposta ); |
| 508 | } else { |
| 509 | $id_resolucio = $proposta.resolucio otherwise $args.resolucio; |
| 510 | $id_requeriment = $proposta.requeriment otherwise $args.requeriment; |
| 511 | |
| 512 | $dades.assignacions[ $id_resolucio || '_' || $id_requeriment ] = { |
| 513 | proposant: $proposta.id_geto otherwise $adr__, |
| 514 | temps: $proposta.temps otherwise timestamp, |
| 515 | resolucio: $id_resolucio, |
| 516 | requeriment: $id_requeriment, |
| 517 | qt: $qt_assignacio, |
| 518 | receptora: $receptora, |
| 519 | unitat: $unitat |
| 520 | }; |
| 521 | response[ 'proposta' ] = $idprop; |
| 522 | response[ 'qt' ] = $qt_assignacio; |
| 523 | response[ 'receptora' ] = $receptora; |
| 524 | response[ 'unitat' ] = $unitat; |
| 525 | var[ 'dades' ] = $dades; |
| 526 | } |
| 527 | response[ 'procés' ] = $proces; |
| 528 | }" |
| 529 | } |
| 530 | ] |
| 531 | }, |
| 532 | { |
| 533 | "if": "{ $proces == 'conversio' }", |
| 534 | "init": "{ |
| 535 | $diposit = $dades_accions.diposits[ $__arg( 'ref' ) ]; |
| 536 | if ( ! $diposit ) { bounce( ': Dipòsit inexistent' ); } |
| 537 | |
| 538 | if ( $adr__ != $diposit.dipositant ) |
| 539 | { bounce( ": L'adreça receptora ha de ser la dipositant" ); } |
| 540 | |
| 541 | if ( $dades.conversions[ $args.ref ] ) |
| 542 | { bounce( ': aquest dipòsit ja ha estat convertit' ); } |
| 543 | |
| 544 | if ( $diposit.cicle_conversio > $cicle_actual ) |
| 545 | { bounce( ": Encara no és l'hora" ); } |
| 546 | |
| 547 | $unitat = |
| 548 | $diposit.geto_diposit == $_estels ? |
| 549 | "base" : |
| 550 | $_estels; |
| 551 | }", |
| 552 | "messages": [ |
| 553 | { |
| 554 | "app": "payment", |
| 555 | "payload": { |
| 556 | "asset": "{ $unitat }", |
| 557 | "outputs": [ |
| 558 | { |
| 559 | "address": "{ $adr__ }", |
| 560 | "amount": "{ $diposit.qt_conversio }" |
| 561 | } |
| 562 | ] |
| 563 | } |
| 564 | }, |
| 565 | { |
| 566 | "app": "state", |
| 567 | "state": "{ |
| 568 | $conversio = |
| 569 | { |
| 570 | temps: timestamp, |
| 571 | qt: $qt, |
| 572 | unitat_conversio: $unitat, |
| 573 | }; |
| 574 | $dades.conversions[ $args.ref ] = $conversio; |
| 575 | response[ 'Conversió realitzada' ] = $args.ref; |
| 576 | response[ 'procés' ] = $proces; |
| 577 | var[ 'dades' ] = $dades; |
| 578 | }" |
| 579 | } |
| 580 | ] |
| 581 | }, |
| 582 | { |
| 583 | "if": "{ $proces == 'retribucio' }", |
| 584 | "init": "{ |
| 585 | if ( $__arg( 'ref' ) == 'aportacio_activacio' ) { |
| 586 | $ref_activacio = 'activacio_' || $adr__ || '_en_' || $_estels; |
| 587 | $activacio = $dades_accions.activacions[ $ref_activacio ]; |
| 588 | $import = $activacio.qt; |
| 589 | $escala = $activacio.escala; |
| 590 | } else { |
| 591 | $contribucio = $dades_accions.contribucions[ $args.ref ]; |
| 592 | |
| 593 | if ( ! $contribucio ) { bounce( ': Contribucio inexistent' ); } |
| 594 | |
| 595 | if ( $adr__ != $contribucio.contribuidora ) |
| 596 | { bounce( ": L'adreça receptora ha de ser la contribuidora" ); } |
| 597 | |
| 598 | $import = $contribucio.qt; |
| 599 | $escala = $contribucio.escala; |
| 600 | } |
| 601 | |
| 602 | $ref_retribucio = $args.ref || '_' || $escala_actual; |
| 603 | |
| 604 | if ( $dades.retribucions[ $ref_retribucio ] ) |
| 605 | { bounce( ": aquesta ja ha estat retribuïda per a l'escala actual" ); } |
| 606 | |
| 607 | |
| 608 | if ( $escala_actual == $escala ) { bounce ( $nom_AA || ": Encara no és l'hora" ); } |
| 609 | |
| 610 | |
| 611 | $qt_retribucio = $import * ( $escala_actual - $escala ); |
| 612 | }", |
| 613 | "messages": [ |
| 614 | { |
| 615 | "app": "payment", |
| 616 | "payload": { |
| 617 | "asset": "{ $_estels }", |
| 618 | "outputs": [ |
| 619 | { |
| 620 | "address": "{ $adr__ }", |
| 621 | "amount": "{ $qt_retribucio }" |
| 622 | } |
| 623 | ] |
| 624 | } |
| 625 | }, |
| 626 | { |
| 627 | "app": "state", |
| 628 | "state": "{ |
| 629 | $retribucio = |
| 630 | { |
| 631 | receptora: $adr__, |
| 632 | qt: $qt_retribucio, |
| 633 | temps: timestamp, |
| 634 | }; |
| 635 | $dades.retribucions[ $ref_retribucio ] = $retribucio; |
| 636 | response[ 'Retribució realitzada' ] = $ref_retribucio; |
| 637 | response[ 'procés' ] = $proces; |
| 638 | var[ 'dades' ] = $dades; |
| 639 | }" |
| 640 | } |
| 641 | ] |
| 642 | }, |
| 643 | { |
| 644 | "if": "{ $operacio AND $operacio == 'proposta' }", |
| 645 | "init": "{ |
| 646 | $args.proces = 'convocatoria_validadores'; |
| 647 | }", |
| 648 | "messages": [ |
| 649 | { |
| 650 | "app": "data", |
| 651 | "payload": "{ $args }" |
| 652 | }, |
| 653 | { |
| 654 | "app": "payment", |
| 655 | "payload": { |
| 656 | "asset": "{ $_unitat }", |
| 657 | "outputs": [ |
| 658 | { |
| 659 | "address": "{ $generics._Validacions }", |
| 660 | "amount": "{ $qt }" |
| 661 | } |
| 662 | ] |
| 663 | } |
| 664 | } |
| 665 | ] |
| 666 | }, |
| 667 | { |
| 668 | "if": "{ $proces == 'decisio_validacio' }", |
| 669 | "messages": [ |
| 670 | { |
| 671 | "app": "data", |
| 672 | "payload": "{ $args }" |
| 673 | }, |
| 674 | { |
| 675 | "app": "payment", |
| 676 | "payload": { |
| 677 | "asset": "{ $_unitat }", |
| 678 | "outputs": [ |
| 679 | { |
| 680 | "address": "{ $generics._Validacions }", |
| 681 | "amount": "{ $qt }" |
| 682 | } |
| 683 | ] |
| 684 | } |
| 685 | } |
| 686 | ] |
| 687 | }, |
| 688 | { |
| 689 | "if": "{ $proces == 'validacio_directa_TEST' AND $_actuant_es_AUT }", |
| 690 | "messages": [ |
| 691 | { |
| 692 | "app": "data", |
| 693 | "payload": "{ $args }" |
| 694 | }, |
| 695 | { |
| 696 | "app": "payment", |
| 697 | "payload": { |
| 698 | "asset": "{ $_unitat }", |
| 699 | "outputs": [ |
| 700 | { |
| 701 | "address": "{ $generics._Validacions }", |
| 702 | "amount": "{ $qt }" |
| 703 | } |
| 704 | ] |
| 705 | } |
| 706 | } |
| 707 | ] |
| 708 | }, |
| 709 | { |
| 710 | "if": "{ $args.admin.entitats }", |
| 711 | "messages": [ |
| 712 | { |
| 713 | "app": "state", |
| 714 | "state": "{ |
| 715 | if ( $proces == 'nova_entitat' ) { |
| 716 | if ( $entitats[ $args.adr ] ) |
| 717 | { bounce( "Ja hi ha una entitat amb aquesta adreça" ); } |
| 718 | |
| 719 | if ( $entitats[ $args.adr ].nom == $__arg( 'nom' ) ) |
| 720 | { bounce( "Ja hi ha una entitat amb aquest nom" ); } |
| 721 | |
| 722 | if ( $operacio == 'proposta' ) { |
| 723 | $dades_proposta = |
| 724 | { |
| 725 | adr: $__arg( 'adr' ), |
| 726 | nom: $args.nom, |
| 727 | estat: $__arg( 'estat' ) |
| 728 | }; |
| 729 | } |
| 730 | response[ 'proposta' ] = $__nova_proposta( $dades_proposta ); |
| 731 | } else { |
| 732 | $adr_entitat = $args.adr otherwise $proposta.adr; |
| 733 | $entitats[ $adr_entitat ] = { |
| 734 | nom: $args.nom otherwise $proposta.nom, |
| 735 | estat: $args.estat otherwise $proposta.estat, |
| 736 | }; |
| 737 | } |
| 738 | |
| 739 | if ( $proces == 'nou_estat_entitat' ) { |
| 740 | if ( ! $entitats[ $args.adr ] ) |
| 741 | { bounce( "No hi ha cap entitat amb aquesta adreça" ); } |
| 742 | |
| 743 | if ( $operacio == 'proposta' ) { |
| 744 | $dades_proposta = { estat: $__arg( 'estat' ) }; |
| 745 | response[ 'proposta' ] = $__nova_proposta( $dades_proposta ); |
| 746 | } else { |
| 747 | $entitats[ $args.adr ].estat = |
| 748 | $args.estat otherwise $proposta.estat; |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | $dades.entitats = $entitats; |
| 753 | var[ 'dades' ] = $dades; |
| 754 | response[ 'procés' ] = $proces; |
| 755 | }" |
| 756 | } |
| 757 | ] |
| 758 | } |
| 759 | ] |
| 760 | } |
| 761 | } |
| 762 | ] |