gld_journal_entry_query.lview 38.9 KB
Newer Older
Spencer Chang's avatar
Spencer Chang committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738
<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: zhangxing5129  
    $Date: 2013-9-2 上午10:16:26  
    $Revision: 1.0  
    $Purpose: 
-->
<a:screen xmlns:a="http://www.leaf-framework.org/application">
    <a:init-procedure>
        <a:model-query defaultWhereClause="t1.enabled_flag=&apos;Y&apos;" model="gld.gld_exchangerate_types_vl" rootPath="exchangerate_type"/>
        <a:model-query fetchAll="true" model="gld.GLD530.gld_company_currency_code" rootPath="company_currency_code"/>
        <a:model-query defaultWhereClause="rownum=1" fetchAll="true" model="fnd.FND2110.fnd_responsibility_centers_lov" rootPath="fnd_responsibility_centers"/>
    </a:init-procedure>
    <a:view>
        <a:link id="sys_service_welcome_link" url="${/request/@context_path}/welcome.lview"/>
        <a:link id="get_exchange_rate_link" url="${/request/@context_path}/autocrud/gld.GLD530.gld_get_exchange_rate/update"/>
        <a:link id="gld_period_num_query_link" url="${/request/@context_path}/autocrud/gld.GLD530.gld_period_num_query/query"/>
        <a:link id="gld_get_journal_num_link" url="${/request/@context_path}/autocrud/gld.GLD530.gld_get_journal_num/query"/>
        <a:link id="gld_journal_status_link" url="${/request/@context_path}/autocrud/gld.GLD530.journal_submit/update"/>
        <a:link id="gld_get_ref_link_id" model="gld.GLD530.gld_get_reference" modelaction="query"/>
        <script type="text/javascript"><![CDATA[
           	 var company_currency_code = '${/model/company_currency_code/record/@functional_currency_code}';
           	 
           	 function quit() {
           	     //location.href = $('sys_service_welcome_link').getUrl();
           	     //parent.shMenu('show');
           	     $('gld310_journal_num_query_window').close();
           	 }
           	 
           	 function save() {
				 //alert('aa');
				 var length = $('gld_journal_details_ds').getAll().length;
				 // if(length>0)
           	     // {
           	         // var record;
           	         // var ref;
           	         // for(var i=0;i<length;i++)
	           	     // {
	           	         // record = $('gld_journal_details_ds').getAt(i);
	           	         // ref = record.getMeta().getField('reference1');
	           	         // if(ref.isRequired())
	           	         // {
	           	            // Leaf.showMessage('${l:PROMPT}', '');
					    	// return;
	           	         // }
	           	     // }
           	     // }
           	     if ($('gld_journal_headers_ds').validate() && $('gld_journal_details_ds').validate()) {
           	         
           	      var document_type=$('gld_journal_headers_ds').getCurrentRecord().get('category_code');	
					var code_auto_flag=$('gld_journal_headers_ds').getCurrentRecord().get('code_auto_flag');
					var total_amount_dr = 0;
					var total_amount_cr = 0;
					var total_amount_fuc_dr = 0;
					var total_amount_fuc_cr = 0;
					var amount_dr;
					var amount_cr;
					var amount_fuc_dr;
					var amount_fuc_cr;
					var length = $('gld_journal_details_ds').getAll().length;
	           	    for(var i=0;i<length;i++)
	           	    {
	           	         amount_dr = $('gld_journal_details_ds').getAt(i).get('amount_dr');
	           	         amount_cr = $('gld_journal_details_ds').getAt(i).get('amount_cr');
	           	         amount_fuc_dr = $('gld_journal_details_ds').getAt(i).get('amount_fuc_dr');
	           	         amount_fuc_cr = $('gld_journal_details_ds').getAt(i).get('amount_fuc_cr');
	           	         amount_dr = amount_dr?amount_dr:0;
	           	         amount_cr = amount_cr?amount_cr:0;
	           	         amount_fuc_dr = amount_fuc_dr?amount_fuc_dr:0;
	           	         amount_fuc_cr = amount_fuc_cr?amount_fuc_cr:0;
	           	         total_amount_dr =plus(total_amount_dr,amount_dr);
	           	         total_amount_cr =plus(total_amount_cr,amount_cr);
	           	         total_amount_fuc_dr =plus(amount_fuc_dr,amount_fuc_dr);
	           	         total_amount_fuc_cr =plus(amount_fuc_cr,amount_fuc_cr);
	           	     }
	           	    // alert(total_amount_dr);
	           	    // alert(total_amount_cr);
	           	     if(total_amount_dr!=total_amount_cr)
	           	     {
	           	        Leaf.showMessage('${l:PROMPT}', '科目借贷不平衡,请重新输入');
					    return;
	           	     }
	           	     $('gld_journal_headers_ds').getCurrentRecord().set('total_amount_dr',total_amount_dr);
	           	     $('gld_journal_headers_ds').getCurrentRecord().set('total_amount_cr',total_amount_cr);
	           	     $('gld_journal_headers_ds').getCurrentRecord().set('total_amount_fuc_dr',total_amount_fuc_dr);
	           	     $('gld_journal_headers_ds').getCurrentRecord().set('total_amount_fuc_cr',total_amount_fuc_cr);										
					 $('gld_journal_headers_ds').submit();
									 Leaf.SideBar.show({
			                            	msg: '保存成功',
			                            	duration: 2000
	                        			});
					 //$('gld530_get_period_name_by_date_ds').query();
						
           	     }
           	 }
           	 
           	 function submit()
           	 {
           	     if($('gld_journal_headers_ds').getCurrentRecord().dirty)
           	     {
           	         Leaf.showMessage('${l:PROMPT}', '${l:HLS.EXECUTE_AFTER_SAVE}');
           	         return;
           	     }
           	     if ($('gld_journal_headers_ds').validate() && $('gld_journal_details_ds').validate())
           	     {           	                    	     
	           	     journal_header_id = $('gld_journal_headers_ds').getCurrentRecord().get('journal_header_id');
	           	 	 Leaf.request({
		           	             url:$('gld_journal_status_link').getUrl(),
		           	             para:{'journal_header_id':journal_header_id},
		           	             success:function (data)
		           	             {
		           	                 $('gld_journal_headers_ds').getCurrentRecord().set('status_desc','已提交');
		           	                 $('gld_journal_headers_ds').getCurrentRecord().set('status','F');
		           	                 Leaf.SideBar.show({
			                            	msg: '提交成功',
			                            	duration: 2000
	                        			});
	                        		$('gld_journal_headers_result_ds').query();
	                        		$('gld310_journal_num_query_window').close();
		           	             }
		           	         });			 	   
           	 	}
           	 }
           	 function add_new() {
           	     $('gld_journal_details_grid1').showEditorByRecord($('gld_journal_details_ds').create());
           	 }
           	 
           	 function gld_journal_headers_ds_update(ds, record, name, value, oldvalue) 
           	 {           	 
           	     if (name == 'currency_code' || name == 'exchange_rate_type') {
           	         if (name == 'currency_code') {
           	             if (value == company_currency_code) {
           	                 record.getField('exchange_rate').setReadOnly(true);
           	                 record.set('exchange_rate', '');
           	                 record.getField('exchange_rate_type_desc').setReadOnly(true);
           	                 record.set('exchange_rate_type_desc', '');
           	                 record.set('exchange_rate_type', '');
           	             } else {
           	                 record.getField('exchange_rate').setReadOnly(false);
           	                 record.getField('exchange_rate_type_desc').setReadOnly(false);
           	             }
           	         }          	 
           	         if (name == 'exchange_rate_type') {
           	             if (value == "MANUAL") {
           	                 record.getField('exchange_rate').setReadOnly(false);
           	             } else {
           	                 record.getField('exchange_rate').setReadOnly(true);
           	                 record.set('exchange_rate', '');
           	             }
           	         }          	            	        
           	         if (record.get('exchange_rate_type') != '' && !Ext.isEmpty(record.get('exchange_rate_type'))) {
           	             var to_currency = record.get('currency_code');
           	             var from_currency = company_currency_code;
           	             var exchange_rate_type = record.get('exchange_rate_type');
           	             var exchange_period_name = record.get('period_name');
           	             paras = {
           	                 'from_currency': from_currency,
           	                 'to_currency': to_currency,
           	                 'exchange_rate_type': exchange_rate_type,
           	                 'exchange_period_name': exchange_period_name
           	             };
           	             Leaf.request({
           	                 url: $('get_exchange_rate_link').getUrl(),
           	                 para: paras,
           	                 success: function(data) {
           	                     if (data.result.exchange_rate) {
           	                         $('gld_journal_headers_ds').getCurrentRecord().set('exchange_rate', data.result.exchange_rate);
           	                     }
           	                 }
           	             });
           	         }
           	     }      	 
           	     // 获取会计期的值
           	    else if (name == 'journal_date') {
           	         var journal_date = value;
           	         $('gld530_get_period_name_by_date_ds').setQueryParameter('journal_date', journal_date);
           	         $('gld530_get_period_name_by_date_ds').query();
           	     }
           	     else if(name == 'description')
	           	 {
	           	     var length = $('gld_journal_details_ds').getAll().length;
	           	     for(var i=0;i<length;i++)
	           	     {
	           	         $('gld_journal_details_ds').getAt(i).set(name,value);
	           	     }
	           	 }
           	     //获取凭证编号
           //	     if(name=='category_code')
           	//     {
           	//
           	//         if(record.get('code_auto_flag')=='Y')
           	 //        {
           	  //           document_type=value;
	          // 	         record.getField('journal_num').setReadOnly(true);
	          // 	         var category_code=value;
	           //	         Leaf.request({
	           //	             url:$('gld_get_journal_num_link').getUrl(),
	           //	             para:{'document_type':document_type},
	           	//             success:function (data)
	           	 //            {
	           	 //
	           	  //               if(data.result)
	           	  //               {
	           	  //
	           	 //                   $('gld_journal_headers_ds').getCurrentRecord().set('journal_num',data.result.record.next_num);
	           	    //             }
	           	   //          }
	           	   //      });
           	      //   }
           	      //   else
           	       //  {
           	        //      record.getField('journal_num').setReadOnly(false);
//}
           	         
           	    // }
           	    
           	     //汇率发生改变,修改本币的值
           	     if(name=='exchange_rate')
           	     {
           	         
           	         var exchange_rate=Ext.isEmpty(value)?1:value;
           	         var details_ds_records=$('gld_journal_details_ds').getAll();
           	         var details_ds_length=details_ds_records.length;
           	         if(details_ds_length>0)
           	         {
           	             for(var i=0;i<details_ds_length;i++)
           	             {
           	                 amount_fuc_dr=exchange_rate*details_ds_records[i].get('amount_dr');
           	                 amount_fuc_cr=exchange_rate*details_ds_records[i].get('amount_cr');
           	            	 details_ds_records[i].set('amount_fuc_dr',amount_fuc_dr);
           	            	 details_ds_records[i].set('amount_fuc_cr',amount_fuc_cr);
           	             }
           	         }
           	     }
           	  
           	     
           	 }
           	 
           	 function gld_period_num_onLoad(ds) {
           	     $('gld_journal_headers_ds').getCurrentRecord().set('period_name','');
           	     $('gld_journal_headers_ds').getCurrentRecord().set('period_year','');
           	     var records = ds.getAll();
           	     if (records.length < 1) {
           	         Leaf.showMessage('没有会计期');
           	     }
           	     else if(records.length == 1){
           	         $('gld_journal_headers_ds').getCurrentRecord().set('period_name',records[0].get('period_name'));
           	         $('gld_journal_headers_ds').getCurrentRecord().set('period_year',records[0].get('period_year'));
           	     }
           	     
           	 }
           	 
           	function gld_journal_details_ds_update(ds,record,name,value,oldvalue)
           	 {
           	     var exchange_rate=$('gld_journal_headers_ds').getCurrentRecord().get('exchange_rate');
           	     if(name=='amount_dr')
           	     {          	         
           	         //如果借方金额输入有值,则将借方金额插入到贷方并将贷方置为只读
           	         if(Math.abs(value)>0)
           	     	 { 
						 if(!Ext.isEmpty(exchange_rate))
	           	         {
		           	         var amount_fuc_dr=exchange_rate*value;
		           	         record.set('amount_fuc_dr',amount_fuc_dr);
		           	         
	           	         }
	           	         else
	           	         {
	           	             record.set('amount_fuc_dr',value);
	           	         }
           	     	 	 //如果本属性不只读则将贷方属性置为可读          	             	     	 	          	     	 	     
           	     	 	     record.getField('amount_cr').setReadOnly(true); 
           	     	 	     //为了光标移动不显示红色
           	     	 	     //record.set('amount_cr',0);
           	     	 	     record.set('amount_cr',null);
							 record.getField('amount_cr').setRequired(false);  	
           	     	 }
           	     	 else if(value=='')
           	     	 {
           	     	     record.getField('amount_dr').setRequired(true);
           	     	     record.getField('amount_dr').setReadOnly(false);
           	     	     record.getField('amount_cr').setRequired(true);
           	     	     record.getField('amount_cr').setReadOnly(false);
           	     	     record.set('amount_fuc_dr',null);
           	     	 }
           	     }
           	      if(name=='amount_cr')
           	     {
           	         
           	         if(Math.abs(value)>0)
           	     	 {           	     	               	     	 	   
						  if(!Ext.isEmpty(exchange_rate))
		           	         {
			           	         var amount_fuc_cr=exchange_rate*value;
			           	         record.set('amount_fuc_cr',amount_fuc_cr);
		           	         }
		           	         else
		           	         {
		           	              record.set('amount_fuc_cr',value);
		           	         }
           	     	 	 
           	     	 	     record.getField('amount_dr').setReadOnly(true); 
           	     	 	     //为了光标移动不显示红色
           	     	 	     //record.set('amount_dr',0);
           	     	 	     record.set('amount_dr',null);
							 record.getField('amount_dr').setRequired(false); 											 
           	     	 }
           	     	 else if(value=='')
           	     	 {
           	     	     record.getField('amount_dr').setRequired(true);
           	     	     record.getField('amount_dr').setReadOnly(false);
           	     	     record.getField('amount_cr').setRequired(true);
           	     	     record.getField('amount_cr').setReadOnly(false);
           	     	     record.set('amount_fuc_cr',null);
           	     	 }
           	     }
           	        if(name=='account_id')
           	     {
                		Leaf.request({
		           	             url:$('gld_get_ref_link_id').getUrl(),
		           	             para:{'account_id':value},
		           	             success:function (data)
		           	             {
									 var reference = record.getMeta().getField('reference1');
		           	                 if(typeof(data.result.record)=='undefined')
		           	                 {
		           	                     record.set('reference1','');
		           	                     reference.setRequired(false);
		           	                     reference.setReadOnly(true);
		           	                     return;
		           	                 }
		           	                 else
		           	                 { 
		           	                     if(data.result.record.type=='SQL_TEST')
		           	                     {
											 var sql_validation = data.result.record.sql_query;
											 reference.setLovService('gld.GLD530.sys_parameter_validate');
											 reference.setLovPara('sql_validation', sql_validation);
		           	                     }
		           	                     else
		           	                     {
		           	                         var category_id = data.result.record.refference_1;
		           	                         reference.setLovService('gld.GLD530.gld_ref_code_values');
											 reference.setLovPara('ref_code_category_id', category_id);
											 
		           	                     }
		           	                     reference.setRequired(true);
		           	                     reference.setReadOnly(false); 
										 //record.set('refference1',0);
										
		           	                 }
		           	                 
		           	             }
		           	         });
           	     }
           	 }
           	 function ok()
           	 {
           	     
           	 }
           	 function gld530_onLoadPeriodName(ds)
           	 {
                record = ds.getAt(0);
                var header_record = $('gld_journal_headers_ds').getAt(0);
                //只有一条记录
                if (ds.getAll().length == 1) {
                     
                    header_record.getField('period_name').setReadOnly(true);
                    header_record.set('period_name', record.get('period_name'));
                    header_record.set('period_num',record.get('period_num'));                                       
                }
                //多条记录 
                else if(ds.getAll().length > 1) 
                {
                    header_record.getField('period_name').setReadOnly(false);
                    header_record.set('period_name','');
                    header_record.set('period_num',''); 
                }                
                else 
                {
                    header_record.set('period_name', '');
                    header_record.set('period_num','');
                    Leaf.showWarningMessage('警告','当前会计期间未打开',ok,200,100);
                }
                header_record.set('period_year',record.get('period_year'));
           	 }
           	 
           	 function gld530_reverse_date_onUpdate()
           	 {
           	     //alert('a');
	           	 if (name == 'reverse_date') {
	                    if (value != '' && value != null) {
	                        $('gld530_get_period_name_by_date_ds').setQueryParameter('journal_date', value);
	                        $('gld530_get_period_name_by_date_ds').query();
	                    }
	           	 }
             }
             
          
             function line_description_render(value,record,name)
             {
                 description = $('gld_journal_headers_ds').getCurrentRecord().get('description');
                 
                 if(Math.abs(record.get('amount_dr'))>0 || Math.abs(record.get('amount_cr'))>0)
                 {
                     if(Math.abs(record.get('amount_dr'))>0)
                 	{       
                 	         //不为读
                 	    	 if(!record.getField('amount_dr').isReadOnly())  	 
                 	    	 {   	     	 	               	     	 	          	     	 	     
	          	     	 	     record.getField('amount_cr').setReadOnly(true); 
	           	     	 	     //为了光标移动不显示红色
	           	     	 	     record.set('amount_cr',null);
								 record.getField('amount_cr').setRequired(false); 
                 			 }
                 	}
                 	else
                 	{
           	     	 	 if(!record.getField('amount_cr').isReadOnly())  	  
           	     	 	 {
           	     	 	     record.getField('amount_dr').setReadOnly(true); 
           	     	 	     //为了光标移动不显示红色
           	     	 	     record.set('amount_dr',null);
							 record.getField('amount_dr').setRequired(false); 
           	     	 	 } 
                 	}
                 }
                 // if(typeof(value)=='undefined')
                 // {
                     // record.set(name,description);
				     // return description;
             	 // }
             	 if(typeof(value)=='undefined'|| 1)
             	 {
             	     record.set(name,description);
             	     return description;
             	 }
             }
             var count=0;
             function gld_journal_details_ds_load(ds)
             {
                 var length = ds.getAll().length;
                  if(length>0)
           	     {
           	         var record;
           	         var ref;
           	         for(var i=0;i<length;i++)
	           	     {
	           	         record = $('gld_journal_details_ds').getAt(i);
	           	         
	           	         if(typeof(record.get('reference1'))!='undefined')
	           	         {
	           	             account_id = record.get('account_id');
	           	             Leaf.request({
		           	             url:$('gld_get_ref_link_id').getUrl(),
		           	             para:{'account_id':account_id},
		           	             
		           	             success:function (data)
		           	             {
									 var reference = record.getMeta().getField('reference1');
		           	                 if(typeof(data.result.record)=='undefined')
		           	                 {
		           	                     reference.setRequired(false);
		           	                     reference.setReadOnly(true);
		           	                 }
		           	                 
		           	                 else
		           	                 { 
		           	                     if(data.result.record.type=='SQL_TEST')
		           	                     {
											 var sql_validation = data.result.record.sql_query;
											 reference.setLovService('gld.GLD530.sys_parameter_validate');
											 reference.setLovPara('sql_validation', sql_validation);
		           	                     }
		           	                     else
		           	                     {
		           	                         var category_id = data.result.record.refference_1;
		           	                         reference.setLovService('gld.GLD530.gld_ref_code_values');
											 reference.setLovPara('ref_code_category_id', category_id);
											 
		           	                     }
		           	                     reference.setRequired(true);
		           	                     reference.setReadOnly(false); 
										 //record.set('refference1',0);
										
		           	                 }		           	                 
		           	             },
		           	             sync:true
		           	         });
	           	         }
	           	     }
           	     }
             }
             
             function summaryRenderer(datas, name) {
                var dr_sum = 0;
              	var cr_sum = 0;
              	var func_dr_sum = 0;
              	var func_cr_sum = 0;
                for (var i = 0;i < datas.length;i++) {
                    record = datas[i];
                    if (name == "amount_dr" ) {
                        var t_1 = record.get("amount_dr" );
                        var  t_2 = parseFloat(t_1);
                        if (!isNaN(t_2)) {
                            dr_sum = plus(dr_sum,t_2);
                        }
                    }
                    if (name == "amount_cr" ) {
                        var d_1 = record.get("amount_cr" );
                        var  d_2 = parseFloat(d_1);
                        if (!isNaN(d_2)) {
                            cr_sum = plus(cr_sum,d_2);
                        }
                    }
                    if (name == "amount_fuc_dr" ) {
                        var a_1 = record.get("amount_fuc_dr" );
                        var  a_2 = parseFloat(a_1);
                        if (!isNaN(a_2)) {
                            func_dr_sum = plus(func_dr_sum,a_2);
                        }
                    }
                    if (name == "amount_fuc_cr" ) {
                        var b_1 = record.get("amount_fuc_cr" );
                        var  b_2 = parseFloat(b_1);
                        if (!isNaN(b_2)) {
                            func_cr_sum = plus(func_cr_sum,b_2);
                        }
                    }
                }
                if (name == "account_description") {
                    return '<div align="right">合计:</div>';
                }
                if (name == "amount_dr" ) {           
                    return '<font color="red">' + Leaf.formatNumber(dr_sum, 2) + '</font>';
                }
                if (name == "amount_cr" ) {           
                    return '<font color="red">' + Leaf.formatNumber(cr_sum, 2) + '</font>';
                } 
                if (name == "amount_fuc_dr" ) {           
                    return '<font color="red">' + Leaf.formatNumber(func_dr_sum, 2) + '</font>';
                }
                if (name == "amount_fuc_cr" ) {           
                    return '<font color="red">' + Leaf.formatNumber(func_cr_sum, 2) + '</font>';
                }
            }
       	 ]]></script>
        <a:dataSets>
            <!-- 	汇率类型 -->
            <a:dataSet id="exchangerate_type_vl_ds">
                <a:datas dataSource="/model/exchangerate_type"/>
            </a:dataSet>
            <a:dataSet id="gld530_status_ds" lookupCode="GLD_JE_STATUS"/>
            <a:dataSet id="gld530_get_period_name_by_date_ds" model="gld.GLD530.gld_period_num_query">
                <a:events>
                    <a:event name="load" handler="gld530_onLoadPeriodName"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="gld530_reverse_date_ds" autoCreate="true">
                <a:fields>
                    <a:field name="reverse_date" defaultValue="${/model/gld533_get_sysdate/record/@currentdate}" required="true"/>
                    <a:field name="reverse_period" displayField="period_name" options="gld530_get_period_name_by_date_ds" readOnly="true" required="true"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="gld530_reverse_date_onUpdate"/>
                </a:events>
            </a:dataSet>
            <!-- 会计期查询 -->
            <a:dataSet id="gld_period_num_ds" loadData="true" queryUrl="${/request/@context_path}/autocrud/gld.GLD530.gld_period_num_query/query">
                <a:events>
                    <a:event name="load" handler="gld_period_num_onLoad"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="gld_journal_headers_ds" autoCreate="true" autoQuery="true" model="gld.GLD530.gld_journal_headers" queryUrl="${/request/@context_path}/autocrud/gld.GLD530.gld_journal_headers/query?journal_header_id=${/parameter/@journal_header_id}" submitUrl="gld_journal_entry_save.lsc">
                <a:fields>
                    <a:field name="total_amount_dr"/>
                    <a:field name="total_amount_cr"/>
                    <a:field name="total_amount_fuc_dr"/>
                    <a:field name="total_amount_fuc_cr"/>
                    <a:field name="exchange_rate"/>
                    <a:field name="exchange_rate_type"/>
                    <a:field name="status" defaultValue="U"/>
                    <a:field name="status_desc" defaultValue="正常" displayField="code_value_name" options="gld530_status_ds" returnField="status" valueField="code_value"/>
                    <a:field name="exchange_rate_type_desc" displayField="type_name" options="exchangerate_type_vl_ds" returnField="exchange_rate_type" valueField="type_code"/>
                    <a:field name="currency_code" defaultValue="${/model/company_currency_code/record/@functional_currency_code}" lovGridHeight="350" lovHeight="500" lovService="basic.gld_currency_v_lov" lovWidth="500" required="true">
                        <a:mapping>
                            <a:map from="currency_code" to="currency_code"/>
                            <a:map from="currency_name" to="currency_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="period_num"/>
                    <a:field name="period_year" required="true"/>
                    <a:field name="attachment_num" defaultValue="1"/>
                    <a:field name="journal_num" readOnly="true"/>
                    <a:field name="source_code" defaultValue="GLD"/>
                    <a:field name="category_code"/>
                    <a:field name="category_code_desc" lovGridHeight="350" lovHeight="500" lovService="gld.GLD530.gld_je_authority_query" lovWidth="450" required="true">
                        <a:mapping>
                            <a:map from="code_auto_flag" to="code_auto_flag"/>
                            <a:map from="document_type" to="category_code"/>
                            <a:map from="document_type_desc" to="category_code_desc"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="journal_date" required="true"/>
                    <a:field name="period_name" displayField="period_name" options="gld530_get_period_name_by_date_ds" readOnly="true" required="true" returnField="period_name" valueField="period_name"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="gld_journal_headers_ds_update"/>
                </a:events>
            </a:dataSet>
            <a:dataSet id="gld_journal_details_ds" autoQuery="true" bindName="result_ds" bindTarget="gld_journal_headers_ds" fetchAll="true" model="gld.GLD530.gld_journal_details" queryUrl="${/request/@context_path}/autocrud/gld.gld_journal_details/query?journal_header_id=${/parameter/@journal_header_id}" selectable="true">
                <a:fields>
                    <a:field name="line_description"/>
                    <a:field name="responsibility_center_id" defaultValue="${/model/fnd_responsibility_centers/record/@responsibility_center_id}"/>
                    <a:field name="responsibility_center_name" defaultValue="${/model/fnd_responsibility_centers/record/@responsibility_center_name}" lovGridHeight="350" lovHeight="550" lovService="fnd.FND2110.fnd_responsibility_centers_lov" lovWidth="500" required="true">
                        <a:mapping>
                            <a:map from="responsibility_center_id" to="responsibility_center_id"/>
                            <a:map from="responsibility_center_name" to="responsibility_center_name"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="account_code" lovGridHeight="350" lovHeight="500" lovService="gld.gld_company_accounts_vl_lov" lovWidth="550" required="true">
                        <a:mapping>
                            <a:map from="account_id" to="account_id"/>
                            <a:map from="description" to="account_description"/>
                            <a:map from="account_code" to="account_code"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="amount_dr" required="true"/>
                    <a:field name="amount_cr" required="true"/>
                    <a:field name="amount_fuc_dr" readOnly="true"/>
                    <a:field name="amount_fuc_cr" readOnly="true"/>
                    <a:field name="reference1" lovGridHeight="250" lovHeight="400" lovWidth="500" readOnly="true" requiredMessage="未选择参考信息">
                        <a:mapping>
                            <a:map from="value_name" to="reference1"/>
                        </a:mapping>
                    </a:field>
                    <a:field name="reference2" readOnly="true"/>
                    <a:field name="reference3" readOnly="true"/>
                    <a:field name="reference4" readOnly="true"/>
                </a:fields>
                <a:events>
                    <a:event name="update" handler="gld_journal_details_ds_update"/>
                    <a:event name="load" handler="gld_journal_details_ds_load"/>
                </a:events>
            </a:dataSet>
        </a:dataSets>
        <a:screenTopToolbar>
            <a:screenTitle/>
            <a:gridButton click="quit" text="关闭"/>
            <a:gridButton click="add_new" text="HLS.NEW"/>
            <a:gridButton click="save" text="HLS.SAVE"/>
            <a:gridButton click="submit" text="提交"/>
        </a:screenTopToolbar>
        <a:form>
            <a:hBox>
                <a:datePicker name="journal_date" bindTarget="gld_journal_headers_ds" prompt="日期"/>
                <a:comboBox name="period_name" bindTarget="gld_journal_headers_ds" prompt="会计期"/>
                <a:textField name="period_year" bindTarget="gld_journal_headers_ds" prompt="年度" readOnly="true"/>
                <a:textField name="status_desc" bindTarget="gld_journal_headers_ds" prompt="状态" readOnly="true"/>
            </a:hBox>
            <a:hBox>
                <a:numberField name="attachment_num" allowDecimals="false" bindTarget="gld_journal_headers_ds" prompt="附件数"/>
                <a:lov name="category_code_desc" bindTarget="gld_journal_headers_ds" prompt="凭证类型"/>
                <a:textField name="journal_num" bindTarget="gld_journal_headers_ds" prompt="凭证编号"/>
                <a:textField name="source_code" bindTarget="gld_journal_headers_ds" prompt="来源" readOnly="true"/>
            </a:hBox>
            <a:hBox>
                <a:lov name="currency_code" bindTarget="gld_journal_headers_ds" prompt="币种"/>
                <a:comboBox name="exchange_rate_type_desc" bindTarget="gld_journal_headers_ds" prompt="汇率类型" readOnly="true"/>
                <a:textField name="exchange_rate" bindTarget="gld_journal_headers_ds" prompt="汇率" readOnly="true"/>
            </a:hBox>
            <a:hBox>
                <a:textField name="description" bindTarget="gld_journal_headers_ds" prompt="摘要" width="616"/>
            </a:hBox>
        </a:form>
        <a:tabPanel marginHeight="215" marginWidth="30">
            <a:tabs>
                <a:tab prompt="基本信息">
                    <a:grid id="gld_journal_details_grid1" bindTarget="gld_journal_details_ds" marginHeight="260" marginWidth="40" navBar="true">
                        <a:toolBar>
                            <a:button type="add"/>
                            <a:button type="delete"/>
                        </a:toolBar>
                        <a:columns>
                            <a:column lock="true" prompt=" ">
                                <a:column name="line_description" editor="gld_journal_details_tf" prompt="摘要" width="200"/>
                                <a:column name="responsibility_center_name" editor="gld_journal_details_lov" prompt="责任中心" width="150"/>
                                <a:column name="account_code" editor="gld_journal_details_lov" prompt="科目"/>
                                <a:column name="account_description" align="left" footerRenderer="summaryRenderer" prompt="描述" width="230"/>
                            </a:column>
                            <a:column prompt="原币">
                                <a:column name="amount_dr" align="right" editor="gld_journal_details_nf" footerRenderer="summaryRenderer" prompt="借方金额" renderer="Leaf.formatMoney"/>
                                <a:column name="amount_cr" align="right" editor="gld_journal_details_nf" footerRenderer="summaryRenderer" prompt="贷方金额" renderer="Leaf.formatMoney"/>
                            </a:column>
                            <a:column prompt="本位币">
                                <a:column name="amount_fuc_dr" align="right" editor="gld_journal_details_nf" footerRenderer="summaryRenderer" prompt="借方金额" renderer="Leaf.formatMoney"/>
                                <a:column name="amount_fuc_cr" align="right" editor="gld_journal_details_nf" footerRenderer="summaryRenderer" prompt="贷方金额" renderer="Leaf.formatMoney"/>
                            </a:column>
                        </a:columns>
                        <a:editors>
                            <a:lov id="gld_journal_details_lov"/>
                            <a:textField id="gld_journal_details_tf"/>
                            <a:numberField id="gld_journal_details_nf"/>
                        </a:editors>
                    </a:grid>
                </a:tab>
                <a:tab prompt="附加信息">
                    <a:grid id="gld_journal_details_grid2" bindTarget="gld_journal_details_ds" marginHeight="260" marginWidth="40" navBar="true">
                        <a:toolBar>
                            <a:button type="add"/>
                            <a:button type="delete"/>
                        </a:toolBar>
                        <a:columns>
                            <a:column lock="true" prompt=" ">
                                <a:column name="line_description" editor="gld_journal_details_grid2_tf" prompt="摘要" renderer="line_description_render" width="200"/>
                                <a:column name="responsibility_center_name" prompt="责任中心" width="150"/>
                                <a:column name="account_code" editor="gld_journal_details_grid2_lov" prompt="科目"/>
                                <a:column name="account_description" align="left" prompt="描述" width="230"/>
                            </a:column>
                            <a:column prompt=" ">
                                <a:column name="reference1" editor="gld_journal_details_grid2_lov" prompt="参考1"/>
                                <a:column name="reference2" editor="gld_journal_details_grid2_tf" prompt="参考2"/>
                                <a:column name="reference3" editor="gld_journal_details_grid2_tf" prompt="参考3"/>
                                <a:column name="reference4" editor="gld_journal_details_grid2_tf" prompt="参考4"/>
                            </a:column>
                        </a:columns>
                        <a:editors>
                            <a:textField id="gld_journal_details_grid2_tf"/>
                            <a:lov id="gld_journal_details_grid2_lov"/>
                        </a:editors>
                    </a:grid>
                </a:tab>
            </a:tabs>
        </a:tabPanel>
        <script type="text/javascript"><![CDATA[
              ]]></script>
    </a:view>
</a:screen>