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