Changeset 3079931
- Timestamp:
- 05/01/2024 02:47:15 PM (2 years ago)
- Location:
- wc-yabi/trunk
- Files:
-
- 5 edited
-
content/settings.php (modified) (1 diff)
-
includes/ajax.php (modified) (3 diffs)
-
includes/transaction.php (modified) (5 diffs)
-
readme.txt (modified) (3 diffs)
-
wc-yabi.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wc-yabi/trunk/content/settings.php
r2644114 r3079931 66 66 <span class="description">xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</span> 67 67 </td> 68 </tr> 69 70 <tr> 71 <th><label for="yabi_url_client"><?php echo __('URL client','yabi-wc'); ?>:</label></th> 72 <td> 73 <input type="text" class="large-text" id="yabi_url_client" name="yabi_url_client" value="<?php echo esc_attr( get_option('yabi_url_client') ); ?>" /><br/> 74 <span class="description">https://api.yabi.co/co/einvoices/v1/</span> 75 </td> 76 </tr> 68 </tr> 77 69 78 70 <tr> -
wc-yabi/trunk/includes/ajax.php
r2958629 r3079931 116 116 ); 117 117 118 if( ' person' == get_option( 'yabi_owner' ))118 if( 'NATURAL' == $person[ 'accountid' ] ) 119 119 { 120 120 $graphQL = yabi_create_invoice_person( $person, $products, $payment ); … … 136 136 echo json_encode( array( 'error' => 1, 'message' => $response['errors'][0]['message'] ) ); 137 137 } 138 elseif( isset( $response['data']['createInvoice'][' invoice']['invoiceUuid'] ) )138 elseif( isset( $response['data']['createInvoice']['document']['uid'] ) ) 139 139 { 140 140 $invoiceConsecutive = get_option('yabi_invoice_name') . get_option('yabi_invoice_number'); … … 143 143 update_option( 'yabi_invoice_number', $yabi_invoice_number ); 144 144 145 $invoiceid = $response['data']['createInvoice'][' invoice']['invoiceUuid'];145 $invoiceid = $response['data']['createInvoice']['document']['uid']; 146 146 147 147 $yabi_invoice = array( -
wc-yabi/trunk/includes/transaction.php
r2958629 r3079931 1 1 <?php 2 3 function yabi_create_commercial( $person )4 {5 $taxlevelcode = $person['taxlevelcode'];6 $pieces = explode( ',', $taxlevelcode );7 $pieceformat = array();8 foreach( $pieces as $p )9 {10 $tax = trim( $p );11 if( !empty( $tax ) )12 {13 array_push( $pieceformat, '"'. $tax .'"' );14 }15 }16 $taxlevelcode = implode( ',', $pieceformat );17 18 if( $person['accountid'] == 'LEGAL' )19 {20 $commercial = 'commercialName:"'. $person['commercialname'] .'"21 partyTaxScheme:{22 taxLevelCode:['. $taxlevelcode .']23 }';24 }25 else26 {27 $commercial = 'partyTaxScheme:{28 taxLevelCode:['. $taxlevelcode .']29 }';30 }31 32 return $commercial;33 }34 2 35 3 function yabi_create_invoice_company( $person, $products, $payment ) 36 4 { 37 $businessUnitUuid = get_option('yabi_businessunituuid'); 38 $invoiceConsecutive = get_option('yabi_invoice_name') . get_option('yabi_invoice_number'); 5 $businessUnitUuid = get_option( 'yabi_businessunituuid' ); 6 $invoice_number = get_option( 'yabi_invoice_number' ); 7 $invoice_name = get_option( 'yabi_invoice_name' ); 39 8 40 9 $data_products = yabi_create_products( $products ); 41 10 $tax_subtotal = yabi_create_tax( $data_products ); 42 11 43 $note = ''; 44 $observations = ''; 45 $commercial = yabi_create_commercial( $person ); 46 47 if( !empty( $person['note_name'] ) && !empty( $person['note_value'] ) ) 48 { 49 $note = 'note:{ 50 name:"'. $person['note_name'] .'" 51 value:"'. $person['note_value'] .'" 52 }'; 53 } 54 55 if( !empty( $person['observations'] ) ) 56 { 57 $observations = 'invoiceOptionalData:[{ 58 name:"Observations" 59 value:"'. $person['observations'] .'" 60 }]'; 12 $graphQL = 'mutation{ 13 createInvoice( 14 document: { 15 organizationalUnitId: "'. $businessUnitUuid .'" 16 id:{ 17 number: '. $invoice_number .' 18 prefix: "'. $invoice_name .'" 19 } 20 generalInformation: { 21 currency: COP 22 issueDateTime: "'. $payment[ 'dateTime' ] .'" 23 acquirerEmail: "'. $person[ 'email' ] .'" 24 operationCode: STD 25 subtypeCode: SALES_INVOICE 26 } 27 documentLines: [ 28 '. $data_products[ 'graphQL' ] .' 29 ] 30 documentParties: { 31 accountingCustomerParty: { 32 additionalAccountId: LEGAL_ENTITY 33 personId: { 34 idType: '. $person[ 'type' ] .' 35 identifier: "'. $person[ 'identifier' ] .'" 36 } 37 personName: { 38 corporateName: "'. $person[ 'commercialname' ] .'" 39 } 40 } 41 } 42 taxDescription: [ 43 { 44 taxName: CO_01 45 taxAmount: "'. $data_products[ 'total_tax' ] .'" 46 roundingAmount: "0" 47 taxSubtotal: [ 48 '. $tax_subtotal .' 49 ] 50 } 51 ] 52 documentTotals: { 53 lineExtensionAmount: "'. $data_products[ 'total_value' ] .'" 54 taxExclusiveAmount: "'. $data_products[ 'total_value' ] .'" 55 taxInclusiveAmount: "'. ( $data_products[ 'total_tax' ] + $data_products[ 'total_value' ] ) .'" 56 payableAmount: "'. ( $data_products[ 'total_tax' ] + $data_products[ 'total_value' ] ) .'" 57 } 58 paymentDescription: { 59 paymentMeans: { 60 paymentMeanCode: CO_ZZZ 61 paymentMeanId: IN_CASH 62 paymentTerms: { 63 locale: ES_CO 64 text: "'. $payment[ 'id' ] .'" 65 } 66 } 67 } 68 } 69 ) 70 { 71 document{ 72 documentUid 73 id 74 uid 75 billingPrefix{ 76 creationDate 77 id 78 prefix 79 range{ 80 from 81 to 82 } 83 } 84 85 documentLines{ 86 description{ 87 locale 88 text 89 } 90 itemDescription{ 91 additionalItemProperty{ 92 key 93 values 94 } 95 brandName 96 informationContentProviderParty{ 97 endpointId{ 98 agencyId 99 id 100 schemeId 101 } 102 identification{ 103 idType{ 104 code 105 description 106 } 107 identifier 108 } 109 name{ 110 corporateName 111 firstName 112 firstSurname 113 secondName 114 secondSurname 115 } 116 partyTaxScheme{ 117 compStringId{ 118 idType{ 119 code 120 description 121 } 122 identifier 123 } 124 partyLegalEntity{ 125 shareholders{ 126 identification{ 127 idType{ 128 code 129 description 130 } 131 identifier 132 } 133 name{ 134 corporateName 135 firstName 136 firstSurname 137 secondName 138 secondSurname 139 } 140 participationPercent 141 physicalLocation{ 142 address 143 cityCode 144 cityName 145 countryCode 146 countrySubentity 147 countrySubentityCode 148 description{ 149 key 150 values 151 } 152 informationUri 153 name 154 postalCode 155 } 156 } 157 } 158 registrationAddress{ 159 address 160 cityCode 161 cityName 162 countryCode 163 countrySubentity 164 countrySubentityCode 165 description{ 166 key 167 values 168 } 169 informationUri 170 name 171 postalCode 172 } 173 registrationName 174 taxLevelCode 175 taxScheme{ 176 code 177 description 178 } 179 } 180 physicalLocation{ 181 address 182 cityCode 183 cityName 184 countryCode 185 countrySubentity 186 countrySubentityCode 187 description{ 188 key 189 values 190 } 191 informationUri 192 name 193 postalCode 194 195 } 196 } 197 manufacturerParty{ 198 endpointId{ 199 agencyId 200 id 201 schemeId 202 } 203 identification{ 204 idType{ 205 code 206 description 207 } 208 identifier 209 } 210 name{ 211 corporateName 212 firstName 213 firstSurname 214 secondName 215 secondSurname 216 } 217 partyTaxScheme{ 218 compStringId{ 219 idType{ 220 code 221 description 222 } 223 identifier 224 } 225 partyLegalEntity{ 226 shareholders{ 227 identification{ 228 idType{ 229 code 230 description 231 } 232 identifier 233 } 234 name{ 235 corporateName 236 firstName 237 firstSurname 238 secondName 239 secondSurname 240 } 241 participationPercent 242 physicalLocation{ 243 address 244 cityCode 245 cityName 246 countryCode 247 countrySubentity 248 countrySubentityCode 249 description{ 250 key 251 values 252 } 253 informationUri 254 name 255 postalCode 256 } 257 } 258 } 259 registrationAddress{ 260 address 261 cityCode 262 cityName 263 countryCode 264 countrySubentity 265 countrySubentityCode 266 description{ 267 key 268 values 269 } 270 informationUri 271 name 272 postalCode 273 } 274 registrationName 275 taxLevelCode 276 taxScheme{ 277 code 278 description 279 } 280 } 281 physicalLocation{ 282 address 283 cityCode 284 cityName 285 countryCode 286 countrySubentity 287 countrySubentityCode 288 description{ 289 key 290 values 291 } 292 informationUri 293 name 294 postalCode 295 } 296 } 297 modelName 298 originCountry{ 299 code 300 description 301 } 302 standardItemId{ 303 id 304 name 305 schemeAgencyId 306 schemeId 307 } 308 } 309 lineExtensionAmount 310 note{ 311 locale 312 text 313 } 314 price{ 315 priceAmount 316 baseQuantity 317 } 318 priceModifier{ 319 amount 320 baseAmount 321 chargeIndicator 322 percentage 323 reason{ 324 text 325 } 326 reasonCode{ 327 code 328 description 329 } 330 } 331 pricingReference{ 332 amount 333 priceType{ 334 code 335 description 336 } 337 } 338 quantity 339 unitCode{ 340 code 341 description 342 } 343 uuid 344 } 345 documentModifiers{ 346 amount 347 baseAmount 348 chargeIndicator 349 percentage 350 reason{ 351 text 352 } 353 reasonCode{ 354 code 355 description 356 } 357 } 358 documentParties{ 359 accountingCustomerParty{ 360 additionalAccountId{ 361 code 362 description 363 } 364 } 365 accountingSupplierParty{ 366 additionalAccountId{ 367 code 368 description 369 } 370 } 371 } 372 documentTotals{ 373 allowanceTotalAmount 374 chargeTotalAmount 375 lineExtensionAmount 376 prePaidAmount 377 taxExclusiveAmount 378 taxInclusiveAmount 379 } 380 documentType 381 generalInformation{ 382 acquirerEmail 383 currency{ 384 code 385 description 386 } 387 environment 388 issueDateTime 389 } 390 id 391 insertedAt 392 organizationalUnitId 393 paymentDescription{ 394 paymentMeans{ 395 paymentDueDate 396 paymentMeanCode{ 397 code 398 description 399 } 400 paymentMeanId{ 401 code 402 description 403 } 404 paymentTerms{ 405 text 406 } 407 } 408 prepayments{ 409 id 410 instructionId 411 paidAmount 412 paidDateTime 413 } 414 } 415 referencedDocuments{ 416 description{ 417 locale 418 text 419 } 420 issueDate 421 referenceId 422 referenceType{ 423 description 424 code 425 } 426 } 427 taxDescription{ 428 taxName{ 429 code 430 description 431 } 432 roundingAmount 433 taxAmount 434 taxSubtotal{ 435 baseUnitMeasureCode{ 436 code 437 description 438 } 439 perUnitAmount 440 taxAmount 441 percent 442 443 taxableAmount 444 } 445 } 446 transactions{ 447 documentId 448 insertedAt 449 requestedAt 450 respondedAt 451 transactionChannel 452 transactionFrom 453 transactionId 454 transactionStage 455 transactionStatus{ 456 message 457 title 458 } 459 transactionTo 460 transactionType 461 updatedAt 462 } 463 updatedAt 464 files{ 465 graphicalRepresentationHtml{ 466 data 467 fileType 468 filename 469 } 470 attachedDocument{ 471 data 472 fileType 473 filename 474 } 475 } 476 } 477 errors{ 478 helpText 479 id 480 language 481 message 482 subType 483 title 484 type 485 } 486 warnings{ 487 helpText 488 id 489 language 490 message 491 subType 492 title 493 type 494 } 495 notifications{ 496 helpText 497 id 498 language 499 message 500 subType 501 title 502 type 503 } 61 504 } 62 63 $invoicetypecode = "SALES_INVOICE"; 64 if( $person['accountid'] == 'LEGAL' ) 65 { 66 $invoicetypecode = "SALES_INVOICE"; 67 } 68 69 $graphQL = 'mutation{ 70 createInvoice(input:{ 71 businessUnitUuid:"'. $businessUnitUuid .'" 72 invoiceAcquirerData:{ 73 additionalAccountId:'. $person['accountid'] .' 74 address:{ 75 countryCode:"CO" 76 cityCode:"'. $person['citycode'] .'" 77 line:"'. $person['address'] .'" 78 } 79 contact:{ 80 email:"'. $person['email'] .'" 81 name:{ 82 firstName:"'. $person['name'] .'" 83 familyName:"'. $person['lastname'] .'" 84 } 85 telephone:"'. $person['telephone'] .'" 86 '. $note .' 87 } 88 '. $commercial .' 89 } 90 invoiceAcquirerId:{ 91 identifier:"'. $person['identifier'] .'" 92 type:'. $person['type'] .' 93 } 94 invoiceConsecutive:"'. $invoiceConsecutive .'" 95 invoiceData:{ 96 invoiceLines:[ 97 '. $data_products['graphQL'] .' 98 ] 99 paymentMeans:{ 100 id:IN_CASH 101 paymentDueDate:"'. $payment['dueDate'] .'" 102 paymentId:"'. $payment['id'] .'" 103 paymentMeansCode:"ZZZ" 104 } 105 } 106 invoiceDetails:{ 107 acquirerEmail:"'. $person['email'] .'" 108 documentCurrencyId:"COP" 109 dueDate:"'. $payment['dueDate'] .'" 110 invoiceTypeCode:'. $invoicetypecode .' 111 issueDateTime:"'. $payment['dateTime'] .'" 112 } 113 '. $observations .' 114 invoiceTaxDetails:[{ 115 id:1 116 taxAmount:'. $data_products['total_tax'] .' 117 taxSchemeId:IVA 118 taxSubtotal:['. $tax_subtotal .'] 119 }] 120 invoiceTotals:{ 121 allowanceTotalAmount:0 122 lineExtensionAmount:'. $data_products['total_value'] .' 123 payableAmount:'. ( $data_products['total_tax'] + $data_products['total_value'] ) .' 124 taxExclusiveAmount:'. $data_products['total_value'] .' 125 taxInclusiveAmount:'. ( $data_products['total_tax'] + $data_products['total_value'] ) .' 126 } 127 }){ 128 invoice{ 129 invoiceUuid 130 invoiceDianLog 131 invoiceDetails 132 } 133 errors{ 134 key 135 message 136 } 137 } 138 } 139 '; 505 }'; 140 506 141 507 return $graphQL; … … 146 512 { 147 513 $businessUnitUuid = get_option( 'yabi_businessunituuid' ); 148 $invoiceConsecutive = get_option( 'yabi_invoice_name' ) . get_option( 'yabi_invoice_number' ); 514 $invoice_number = get_option( 'yabi_invoice_number' ); 515 $invoice_name = get_option( 'yabi_invoice_name' ); 149 516 150 517 $data_products = yabi_create_products( $products ); 151 518 $tax_subtotal = yabi_create_tax( $data_products ); 152 519 153 $note = ''; 154 $observations = ''; 155 $commercial = yabi_create_commercial( $person ); 156 157 if( !empty( $person['note_name'] ) && !empty( $person['note_value'] ) ) 158 { 159 $note = 'note:{ 160 name:"'. $person['note_name'] .'" 161 value:"'. $person['note_value'] .'" 162 }'; 163 } 164 165 if( !empty( $person['observations'] ) ) 166 { 167 $observations = 'invoiceOptionalData:[{ 168 name:"Observations" 169 value:"'. $person['observations'] .'" 170 }]'; 520 $graphQL = 'mutation{ 521 createInvoice( 522 document: { 523 organizationalUnitId: "'. $businessUnitUuid .'" 524 id:{ 525 number: '. $invoice_number .' 526 prefix: "'. $invoice_name .'" 527 } 528 generalInformation: { 529 currency: COP 530 issueDateTime: "'. $payment[ 'dateTime' ] .'" 531 acquirerEmail: "'. $person[ 'email' ] .'" 532 operationCode: STD 533 subtypeCode: SALES_INVOICE 534 } 535 documentLines: [ 536 '. $data_products[ 'graphQL' ] .' 537 ] 538 documentParties: { 539 accountingCustomerParty: { 540 additionalAccountId: NATURAL_PERSON 541 personId: { 542 idType: '. $person[ 'type' ] .' 543 identifier: "'. $person[ 'identifier' ] .'" 544 } 545 personName: { 546 firstName: "'. $person[ 'name' ] .'" 547 secondName: "" 548 firstSurname: "'. $person[ 'lastname' ] .'" 549 secondSurname: "" 550 } 551 } 552 } 553 taxDescription: [ 554 { 555 taxName: CO_01 556 taxAmount: "'. $data_products[ 'total_tax' ] .'" 557 roundingAmount: "0" 558 taxSubtotal: [ 559 '. $tax_subtotal .' 560 ] 561 } 562 ] 563 documentTotals: { 564 lineExtensionAmount: "'. $data_products[ 'total_value' ] .'" 565 taxExclusiveAmount: "'. $data_products[ 'total_value' ] .'" 566 taxInclusiveAmount: "'. ( $data_products[ 'total_tax' ] + $data_products[ 'total_value' ] ) .'" 567 payableAmount: "'. ( $data_products[ 'total_tax' ] + $data_products[ 'total_value' ] ) .'" 568 } 569 paymentDescription: { 570 paymentMeans: { 571 paymentMeanCode: CO_ZZZ 572 paymentMeanId: IN_CASH 573 paymentTerms: { 574 locale: ES_CO 575 text: "'. $payment[ 'id' ] .'" 576 } 577 } 578 } 579 } 580 ) 581 { 582 document{ 583 documentUid 584 id 585 uid 586 billingPrefix{ 587 creationDate 588 id 589 prefix 590 range{ 591 from 592 to 593 } 594 } 595 596 documentLines{ 597 description{ 598 locale 599 text 600 } 601 itemDescription{ 602 additionalItemProperty{ 603 key 604 values 605 } 606 brandName 607 informationContentProviderParty{ 608 endpointId{ 609 agencyId 610 id 611 schemeId 612 } 613 identification{ 614 idType{ 615 code 616 description 617 } 618 identifier 619 } 620 name{ 621 corporateName 622 firstName 623 firstSurname 624 secondName 625 secondSurname 626 } 627 partyTaxScheme{ 628 compStringId{ 629 idType{ 630 code 631 description 632 } 633 identifier 634 } 635 partyLegalEntity{ 636 shareholders{ 637 identification{ 638 idType{ 639 code 640 description 641 } 642 identifier 643 } 644 name{ 645 corporateName 646 firstName 647 firstSurname 648 secondName 649 secondSurname 650 } 651 participationPercent 652 physicalLocation{ 653 address 654 cityCode 655 cityName 656 countryCode 657 countrySubentity 658 countrySubentityCode 659 description{ 660 key 661 values 662 } 663 informationUri 664 name 665 postalCode 666 } 667 } 668 } 669 registrationAddress{ 670 address 671 cityCode 672 cityName 673 countryCode 674 countrySubentity 675 countrySubentityCode 676 description{ 677 key 678 values 679 } 680 informationUri 681 name 682 postalCode 683 } 684 registrationName 685 taxLevelCode 686 taxScheme{ 687 code 688 description 689 } 690 } 691 physicalLocation{ 692 address 693 cityCode 694 cityName 695 countryCode 696 countrySubentity 697 countrySubentityCode 698 description{ 699 key 700 values 701 } 702 informationUri 703 name 704 postalCode 705 } 706 } 707 manufacturerParty{ 708 endpointId{ 709 agencyId 710 id 711 schemeId 712 } 713 identification{ 714 idType{ 715 code 716 description 717 } 718 identifier 719 } 720 name{ 721 corporateName 722 firstName 723 firstSurname 724 secondName 725 secondSurname 726 } 727 partyTaxScheme{ 728 compStringId{ 729 idType{ 730 code 731 description 732 } 733 identifier 734 } 735 partyLegalEntity{ 736 shareholders{ 737 identification{ 738 idType{ 739 code 740 description 741 } 742 identifier 743 } 744 name{ 745 corporateName 746 firstName 747 firstSurname 748 secondName 749 secondSurname 750 } 751 participationPercent 752 physicalLocation{ 753 address 754 cityCode 755 cityName 756 countryCode 757 countrySubentity 758 countrySubentityCode 759 description{ 760 key 761 values 762 } 763 informationUri 764 name 765 postalCode 766 } 767 } 768 } 769 registrationAddress{ 770 address 771 cityCode 772 cityName 773 countryCode 774 countrySubentity 775 countrySubentityCode 776 description{ 777 key 778 values 779 } 780 informationUri 781 name 782 postalCode 783 } 784 registrationName 785 taxLevelCode 786 taxScheme{ 787 code 788 description 789 } 790 } 791 physicalLocation{ 792 address 793 cityCode 794 cityName 795 countryCode 796 countrySubentity 797 countrySubentityCode 798 description{ 799 key 800 values 801 } 802 informationUri 803 name 804 postalCode 805 } 806 } 807 modelName 808 originCountry{ 809 code 810 description 811 } 812 standardItemId{ 813 id 814 name 815 schemeAgencyId 816 schemeId 817 } 818 } 819 lineExtensionAmount 820 note{ 821 locale 822 text 823 } 824 price{ 825 priceAmount 826 baseQuantity 827 } 828 priceModifier{ 829 amount 830 baseAmount 831 chargeIndicator 832 percentage 833 reason{ 834 text 835 } 836 reasonCode{ 837 code 838 description 839 } 840 } 841 pricingReference{ 842 amount 843 priceType{ 844 code 845 description 846 } 847 } 848 quantity 849 unitCode{ 850 code 851 description 852 } 853 uuid 854 } 855 documentModifiers{ 856 amount 857 baseAmount 858 chargeIndicator 859 percentage 860 reason{ 861 text 862 } 863 reasonCode{ 864 code 865 description 866 } 867 } 868 documentParties{ 869 accountingCustomerParty{ 870 additionalAccountId{ 871 code 872 description 873 } 874 } 875 accountingSupplierParty{ 876 additionalAccountId{ 877 code 878 description 879 } 880 } 881 } 882 documentTotals{ 883 allowanceTotalAmount 884 chargeTotalAmount 885 lineExtensionAmount 886 prePaidAmount 887 taxExclusiveAmount 888 taxInclusiveAmount 889 } 890 documentType 891 generalInformation{ 892 acquirerEmail 893 currency{ 894 code 895 description 896 } 897 environment 898 issueDateTime 899 } 900 id 901 insertedAt 902 organizationalUnitId 903 paymentDescription{ 904 paymentMeans{ 905 paymentDueDate 906 paymentMeanCode{ 907 code 908 description 909 } 910 paymentMeanId{ 911 code 912 description 913 } 914 paymentTerms{ 915 text 916 } 917 } 918 prepayments{ 919 id 920 instructionId 921 paidAmount 922 paidDateTime 923 } 924 } 925 referencedDocuments{ 926 description{ 927 locale 928 text 929 } 930 issueDate 931 referenceId 932 referenceType{ 933 description 934 code 935 } 936 } 937 taxDescription{ 938 taxName{ 939 code 940 description 941 } 942 roundingAmount 943 taxAmount 944 taxSubtotal{ 945 baseUnitMeasureCode{ 946 code 947 description 948 } 949 perUnitAmount 950 taxAmount 951 percent 952 953 taxableAmount 954 } 955 } 956 transactions{ 957 documentId 958 insertedAt 959 requestedAt 960 respondedAt 961 transactionChannel 962 transactionFrom 963 transactionId 964 transactionStage 965 transactionStatus{ 966 message 967 title 968 } 969 transactionTo 970 transactionType 971 updatedAt 972 } 973 updatedAt 974 files{ 975 graphicalRepresentationHtml{ 976 data 977 fileType 978 filename 979 } 980 attachedDocument{ 981 data 982 fileType 983 filename 984 } 985 } 986 } 987 errors{ 988 helpText 989 id 990 language 991 message 992 subType 993 title 994 type 995 } 996 warnings{ 997 helpText 998 id 999 language 1000 message 1001 subType 1002 title 1003 type 1004 } 1005 notifications{ 1006 helpText 1007 id 1008 language 1009 message 1010 subType 1011 title 1012 type 1013 } 171 1014 } 172 173 $invoicetypecode = "SALES_INVOICE"; 174 if( $person['accountid'] == 'LEGAL' ) 175 { 176 $invoicetypecode = "SALES_INVOICE"; 177 } 178 179 $graphQL = 'mutation{ 180 createInvoice(input:{ 181 businessUnitUuid:"'. $businessUnitUuid .'" 182 invoiceConsecutive:"'. $invoiceConsecutive .'" 183 invoiceAcquirerId:{ 184 identifier:"'. $person['identifier'] .'" 185 type:'. $person['type'] .' 186 } 187 invoiceAcquirerData:{ 188 additionalAccountId:'. $person['accountid'] .' 189 address:{ 190 countryCode:"CO" 191 cityCode:"'. $person['citycode'] .'" 192 line:"'. $person['address'] .'" 193 } 194 contact:{ 195 email:"'. $person['email'] .'" 196 name:{ 197 firstName:"'. $person['name'] .'" 198 familyName:"'. $person['lastname'] .'" 199 } 200 telephone:"'. $person['telephone'] .'" 201 '. $note .' 202 } 203 '. $commercial .' 204 } 205 invoiceDetails:{ 206 acquirerEmail:"'. $person['email'] .'" 207 documentCurrencyId:"COP" 208 dueDate:"'. $payment['dueDate'] .'" 209 invoiceOperationCode:STANDARD 210 invoiceTypeCode:'. $invoicetypecode .' 211 issueDateTime:"'. $payment['dateTime'] .'" 212 } 213 invoiceData:{ 214 invoiceLines:[ 215 '. $data_products['graphQL'] .' 216 ] 217 paymentMeans:{ 218 id:CREDIT 219 paymentDueDate:"'. $payment['dueDate'] .'" 220 paymentId:"'. $payment['id'] .'" 221 paymentMeansCode:"ZZZ" 222 } 223 } 224 invoiceTaxDetails:[{ 225 id:1 226 taxAmount:'. $data_products['total_tax'] .' 227 taxSchemeId:IVA 228 taxSubtotal:['. $tax_subtotal .'] 229 }] 230 invoiceTotals:{ 231 allowanceTotalAmount:0 232 chargeTotalAmount:0 233 lineExtensionAmount:'. $data_products['total_value'] .' 234 payableAmount:'. ( $data_products['total_tax'] + $data_products['total_value'] ) .' 235 prepaidAmount:0 236 taxExclusiveAmount:'. $data_products['total_value'] .' 237 taxInclusiveAmount:'. ( $data_products['total_tax'] + $data_products['total_value'] ) .' 238 } 239 '. $observations .' 240 }){ 241 invoice{ 242 invoiceUuid 243 invoiceDianLog 244 invoiceDetails 245 } 246 } 247 } 248 '; 1015 }'; 249 1016 250 1017 return $graphQL; … … 274 1041 275 1042 $basevalue = round( ( floatval( $item['value'] ) / intval( $item['quantity'] ) ), 2 ); 276 277 $data['graphQL'] .= '{ 278 description:"'. $item['description'] .'" 279 id:'. $idsequence .' 280 lineExtensionAmount:'. $item['value'] .' 281 price:{ 282 baseQuantity:1 283 currencyId:"COP" 284 unitCode:"UnitCode" 285 value:'. $basevalue .' 286 } 287 quantity:'. $item['quantity'] .' 288 standardItemId:{ 289 agencyId:OFE_STD 290 id:"'. $item['id'] .'" 291 name:OFE_STD 292 schemaId:OFE_STD 293 } 294 taxTotals:[{ 295 id:1 296 taxSchemeId:IVA 297 taxSubtotal:{ 298 percent:'. $item['percent'] .' 299 taxAmount:'. $item['tax'] .' 300 taxableAmount:'. $item['value'] .' 301 } 302 }] 303 unit:"Unit" 304 }'; 305 306 $idsequence++; 1043 1044 $data[ 'graphQL' ] .= '{ 1045 description: { 1046 locale: ES_CO 1047 text: "'. $item[ 'description' ] .'" 1048 } 1049 itemDescription: { 1050 standardItemId: { 1051 id: "'. $item[ 'id' ] .'" 1052 standardId: GTIN 1053 } 1054 incomeType: SELF_OWNED 1055 } 1056 lineExtensionAmount: "'. $item[ 'value' ] .'" 1057 lineId: 1 1058 price: { 1059 priceAmount: "'. $basevalue .'" 1060 baseQuantity: 1 1061 unitCode: CO_ZZ 1062 priceType: COMMERCIAL_VALUE 1063 } 1064 quantity: "'. $item[ 'quantity' ] .'" 1065 taxDescription: [ 1066 { 1067 taxName: CO_01 1068 taxAmount: "'. $item[ 'tax' ] .'" 1069 roundingAmount: "0" 1070 taxSubtotal: [ 1071 { 1072 taxAmount: "'. $item[ 'tax' ] .'" 1073 percent: '. $item[ 'percent' ] .' 1074 taxableAmount: "'. $item[ 'value' ] .'" 1075 } 1076 ] 1077 } 1078 ] 1079 unitCode: CO_ZZ 1080 }'; 307 1081 } 308 1082 … … 314 1088 $tax_data = ''; 315 1089 316 foreach( $data_products[ 'total_tax_type'] as $percent => $value )1090 foreach( $data_products[ 'total_tax_type' ] as $percent => $value ) 317 1091 { 318 1092 $tax_data .= '{ 319 percent:'. $percent .'320 taxAmount:'. $value .'321 taxableAmount: '. $data_products['total_value_type'][$percent] .'322 }';1093 taxAmount: "'. $value .'" 1094 percent: '. $percent .' 1095 taxableAmount: "'. $data_products[ 'total_value_type' ][ $percent ] .'" 1096 }'; 323 1097 } 324 1098 … … 330 1104 $result = false; 331 1105 $token = get_option('yabi_token'); 332 $url = get_option('yabi_url_client');1106 $url = 'https://api.yabi.co/co/einvoices/v2/'; 333 1107 334 1108 $post_data = json_encode( array( 'query' => $graphQL ) ); -
wc-yabi/trunk/readme.txt
r2958629 r3079931 3 3 Tags: woocommerce, electronic invoice 4 4 Donate link: https://www.paypal.me/datakun 5 Requires at least: 6. 06 Tested up to: 6. 35 Requires at least: 6.4 6 Tested up to: 6.5.2 7 7 Requires PHP: 8.0 8 8 Stable tag: trunk … … 76 76 77 77 == Changelog == 78 = 1.0 =78 = 1.0.0 = 79 79 * Initial release 80 = 1.1 =80 = 1.1.0 = 81 81 * Fixed problem with decimal numbers in purchases of more than one item 82 82 = 1.1.1 = 83 83 * Timeout was increased as Yabi servers started experiencing service delays 84 = 1.2 =84 = 1.2.0 = 85 85 * Update to 1.8 Version of Yabi 86 86 * Change numeric variables to strings 87 = 1.3 =87 = 1.3.0 = 88 88 * A selection box was created to be able to select the city code 89 89 * Change default tax level code for natural person … … 105 105 * Better error report, database save mutation for debug 106 106 * Tested in last WP Version 107 = 2.0.0 = 108 * Update to 2.0 Version of Yabi 109 * Tested in last WP Version -
wc-yabi/trunk/wc-yabi.php
r2958629 r3079931 9 9 * Plugin URI: https://mireunion.com/yabi 10 10 * Description: Create your electronic invoices of purchases made in woocommerce with Yabi 11 * Version: 1.8.011 * Version: 2.0.0 12 12 * Author: Mex Avila 13 13 * Author URI: https://datakun.com/ … … 163 163 $yabi_businessunituuid = sanitize_key( $_POST['yabi_businessunituuid'] ); 164 164 $yabi_token = sanitize_key( $_POST['yabi_token'] ); 165 $yabi_url_client = esc_url_raw( $_POST['yabi_url_client'] );166 165 167 166 update_option( 'yabi_invoice_name', $yabi_invoice_name ); … … 170 169 update_option( 'yabi_businessunituuid', $yabi_businessunituuid ); 171 170 update_option( 'yabi_token', $yabi_token ); 172 update_option( 'yabi_url_client', $yabi_url_client );173 171 } 174 172
Note: See TracChangeset
for help on using the changeset viewer.