Skip to content

Commit

Permalink
Merged recent changes, 1.2.8, into master
Browse files Browse the repository at this point in the history
  • Loading branch information
renatonascalves committed Nov 21, 2018
1 parent 0cfc9f2 commit f8df2e9
Show file tree
Hide file tree
Showing 12 changed files with 289 additions and 195 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Ou você pode colocar este plugin no diretório wp-content/plugins e ativá-lo.

## Changelog ##

### 1.0
### 1.0.0
* Initial release

### 1.0.1
Expand Down Expand Up @@ -50,3 +50,13 @@ Ou você pode colocar este plugin no diretório wp-content/plugins e ativá-lo.

### 1.2.7
* Fixing how we verify the type of customer to output its information on the NFe receipt.

### 1.2.8
* Improved code documentation, PHPDoc.
* Started to use `[]` instead of `array()`.
* Started to use the new logger implementation, `wc_get_logger()`.
* Updated WordPress tested header to 3.5.1.
* Removed Extra Checkout plugin dependency.
* Removed Composer support for the client-php.
* Removed checks when on automatic issuing, as it was avoiding important log information to be saved.
* Added better labeling for the NFe.io `flowStatus`.
14 changes: 12 additions & 2 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Contributors: nfe, espellcaste
Tags: woocommerce, shop, receipt, nfe, nota fiscal, nota, receita, sefaz, nfse, emitir nfse, emitir nfe
Requires at least: 4.7
Tested up to: 4.9.4
Stable tag: 1.2.7
Stable tag: 1.2.8
Requires PHP: 5.5
WC tested up to: 3.4.3
WC tested up to: 3.5.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -66,3 +66,13 @@ or

= 1.2.7 =
* Fixing how we verify the type of customer to output its information on the NFe receipt.

= 1.2.8 =
* Improved code documentation, PHPDoc.
* Started to use `[]` instead of `array()`.
* Started to use the new logger implementation, `wc_get_logger()`.
* Updated WordPress tested header to 3.5.1.
* Removed Extra Checkout plugin dependency.
* Removed Composer support for the client-php.
* Removed checks when on automatic issuing, as it was avoiding important log information to be saved.
* Added better labeling for the NFe.io `flowStatus`.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"composer/installers": "~1.0"
},
"require-dev": {
"phpunit/phpunit": ">=3.7@stable",
"nfe/nfe": ">=2.0"
"phpunit/phpunit": ">=3.7@stable"
}
}
46 changes: 19 additions & 27 deletions includes/admin/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,35 +61,28 @@ public function __construct() {
* Issue a NFe receipt when WooCommerce does its thing.
*
* @param int $order_id Order ID.
*
* @return void
*/
public function issue_trigger( $order_id ) {

// Bail early.
if ( nfe_get_field( 'issue_when' ) === 'manual' ) {
return;
}

// Check if order exists first.
$order = nfe_wc_get_order( $order_id );
$order = nfe_wc_get_order( $order_id );
$order_id = $order->get_id();

// Bail for no order.
if ( ! $order_id ) {
return;
}

// Bail for zeroed order.
if ( '0.00' === $order->get_total() ) {
return;
}

// Checking if the address is required and if the order address was filled.
if ( ! nfe_order_address_filled( $order_id ) ) {
return;
}

// We just can issue the invoice if the status is equal to the configured one.
// We just can issue the invoice automatically if the status is equal to the configured one.
if ( $order->has_status( nfe_get_field( 'issue_when_status' ) ) ) {
NFe_Woo()->issue_invoice( array( $order_id ) );
NFe_Woo()->issue_invoice( [ $order_id ] );
}
}

Expand Down Expand Up @@ -179,9 +172,9 @@ public function nfe_status_widget_order_rows() {
*/
public function product_data_tab( $product_data_tabs ) {
$product_data_tabs['nfe-product-info-tab'] = array(
'label' => esc_html__( 'WooCommerce NFe', 'woo-nfe' ),
'target' => 'nfe_product_info_data',
'class' => array( 'hide_if_variable' ),
'label' => esc_html__( 'WooCommerce NFe', 'woo-nfe' ),
'target' => 'nfe_product_info_data',
'class' => array( 'hide_if_variable' ),
);
return $product_data_tabs;
}
Expand Down Expand Up @@ -307,7 +300,7 @@ public function save_variations_fields( $post_id ) {
* Adds the Download and Issue actions to the actions list in the order edit page.
*
* @param array $actions Order actions array to display.
* @return array List of actions.
* @return array|void List of actions.
*/
public function download_and_issue_actions( $actions ) {
global $theorder;
Expand Down Expand Up @@ -390,9 +383,9 @@ public function order_status_column_header( $columns ) {
public function order_status_column_content( $column ) {

// Get information.
$order = nfe_wc_get_order( get_the_ID() );
$order_id = $order->get_id();
$nfe = get_post_meta( $order_id, 'nfe_issued', true );
$order = nfe_wc_get_order( get_the_ID() );
$order_id = $order->get_id();
$nfe = get_post_meta( $order_id, 'nfe_issued', true );

// Bail early.
if ( 'nfe_receipts' !== $column ) {
Expand Down Expand Up @@ -490,7 +483,7 @@ public function display_order_data_preview_in_admin( $order ) {
<p>
<strong><?php esc_html_e( 'Status: ', 'woo-nfe' ); ?></strong>
<?php if ( ! empty( $nfe['status'] ) ) : ?>
<?php echo esc_html( $nfe['status'] ); ?>
<?php echo esc_html( nfe_status_label( $nfe['status'] ) ); ?>
<?php endif; ?>
<br />

Expand Down Expand Up @@ -542,7 +535,7 @@ public function nfe_admin_order_preview_details( $fields, $order ) {
}

$fields['nfe'] = [
'status' => ! empty( $nfe['status'] ) ? $nfe['status'] : '',
'status' => ! empty( $nfe['status'] ) ? nfe_status_label( $nfe['status'] ) : '',
'number' => ! empty( $nfe['number'] ) ? $nfe['number'] : '',
'check_code' => ! empty( $nfe['checkCode'] ) ? $nfe['checkCode'] : '',
'issued' => ! empty( $nfe['issuedOn'] ) ? date_i18n( get_option( 'date_format' ), strtotime( $nfe['issuedOn'] ) ) : '',
Expand Down Expand Up @@ -597,8 +590,7 @@ public function nfe_admin_order_preview() {
* @return void
*/
public function register_enqueue_css() {
wp_register_style( 'nfe-woo-admin-css', plugins_url( 'woo-nfe/assets/css/nfe' ) . '.css' );
wp_enqueue_style( 'nfe-woo-admin-css' );
wp_enqueue_style( 'nfe-woo-admin-css', plugins_url( 'woo-nfe/assets/css/nfe' ) . '.css', [], '1.2.8', false );
}

/**
Expand Down Expand Up @@ -636,7 +628,7 @@ protected function array_insert_after( $needle, $haystack, $new_key, $new_value
* Issue Helper Method.
*
* @param array $download NFe info.
* @param WC_Order $order Order.
* @param WC_Order $order Order object.
*
* @return bool
*/
Expand All @@ -652,8 +644,8 @@ protected function should_we_issue( $download, $order ) {
return false;
}

// Bail if there is no address.
if ( ! nfe_order_address_filled( $order->get_id() ) ) {
// Bail if there is no address and it is required.
if ( nfe_require_address() && ! nfe_order_address_filled( $order->get_id() ) ) {
return false;
}

Expand Down
Loading

0 comments on commit f8df2e9

Please sign in to comment.