Skip to content

Commit

Permalink
Merge pull request #150 from vektor-inc/develop
Browse files Browse the repository at this point in the history
1.4.0
  • Loading branch information
kurudrive committed Sep 7, 2020
2 parents 7dcc062 + 3d59692 commit 9c3aa1b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 20 deletions.
47 changes: 30 additions & 17 deletions inc/export/class.csv-export.php
Expand Up @@ -12,8 +12,6 @@ public static function init() {
public static function export_csv() {
if ( isset( $_GET['action'] ) && ( $_GET['action'] == 'csv_mf' || $_GET['action'] == 'csv_freee' ) ) {

/*
-------------------------------------------*/
/*
CSVに出力する項目と順番
/*-------------------------------------------*/
Expand Down Expand Up @@ -53,12 +51,12 @@ public static function export_csv() {
),
),
);
if ( isset( $_GET['client'] ) && $_GET['client'] ) {
if ( isset( $_GET['bill_client'] ) && $_GET['bill_client'] ) {
$args['meta_query'] = array(
// 'relation' => 'AND',
array(
'key' => 'bill_client',
'value' => esc_html( $_GET['client'] ),
'value' => esc_html( $_GET['bill_client'] ),
'type' => 'NUMERIC',
'compare' => '=',
),
Expand All @@ -68,17 +66,22 @@ public static function export_csv() {

$number = ( isset( $_GET['number_start'] ) && $_GET['number_start'] ) ? esc_html( $_GET['number_start'] ) : '';

/*
-------------------------------------------*/
/*
売掛金用のレコード出力
/*-------------------------------------------*/
foreach ( $posts as $key => $post ) {

setup_postdata($GLOBALS['post'] =& $post);

$date = date_i18n( 'Y/n/j', strtotime( $post->post_date ) );
$bill_limit_date = get_post_meta( $post->ID, 'bill_limit_date', true );
$date_pay = date( 'Y/n/j', bill_raw_date( $bill_limit_date ) );
$bill_total_add_tax = bill_total_add_tax( $post );
$tax = round( bill_total_no_tax( $post ) * 0.08 );
if ( 'tax_not_auto' === get_post_meta( $post->ID, 'bill_tax_type', true ) ) {
$bill_total_price = bill_total_no_tax( $post );
} else {
$bill_total_price = bill_total_add_tax( $post );
}
$tax = bill_tax( bill_total_no_tax( $post ) );

// 取引先名(省略名があれば省略名で表示)
$client_name = get_post_meta( $post->bill_client, 'client_short_name', true );
Expand All @@ -97,13 +100,13 @@ public static function export_csv() {
$c[] = '""'; // 借方補助科目
$c[] = '"対象外"'; // 借方税区分
$c[] = '""'; // 借方部門
$c[] = '"' . $bill_total_add_tax . '"'; // 借方金額(円)
$c[] = '"' . $bill_total_price . '"'; // 借方金額(円)
$c[] = '""'; // 借方税額
$c[] = '"売上高"'; // 貸方勘定科目
$c[] = '""'; // 貸方補助科目
$c[] = '"課売 ' . $tax_rate . '% 五種"'; // 貸方税区分
$c[] = '""'; // 貸方部門
$c[] = '"' . $bill_total_add_tax . '"'; // 貸方金額(円)
$c[] = '"' . $bill_total_price . '"'; // 貸方金額(円)
$c[] = '""'; // 貸方税額
$c[] = '"[ ' . esc_html( $client_name ) . ' ] ' . esc_html( $post->post_title ) . '"'; // 摘要
$c[] = '""'; // 仕訳メモ
Expand All @@ -124,7 +127,7 @@ public static function export_csv() {
$c[] = '"' . esc_html( $client_name ) . '"'; // 取引先
$c[] = '"売上高"'; // 勘定科目
$c[] = '"課税' . $tax_rate . '%"'; // 税区分
$c[] = '"' . $bill_total_add_tax . '"'; // 金額(円)
$c[] = '"' . $bill_total_price . '"'; // 金額(円)
$c[] = '"内税"'; // 税計算区分
$c[] = '"' . $tax . '"'; // 税額
$c[] = '""'; // 備考
Expand All @@ -144,17 +147,24 @@ public static function export_csv() {
}
}

wp_reset_postdata();

if ( $_GET['action'] == 'csv_mf' ) {
/*
-------------------------------------------*/

/*
売掛金の入金用レコード
/*-------------------------------------------*/
foreach ( $posts as $key => $post ) {

setup_postdata($GLOBALS['post'] =& $post);

$bill_limit_date = get_post_meta( $post->ID, 'bill_limit_date', true );
$date_pay = date( 'Y/n/j', bill_raw_date( $bill_limit_date ) );
$bill_total_add_tax = bill_total_add_tax( $post );

if ( 'tax_not_auto' === get_post_meta( $post->ID, 'bill_tax_type', true ) ) {
$bill_total_price = bill_total_no_tax( $post );
} else {
$bill_total_price = bill_total_add_tax( $post );
}
// 取引先名(省略名があれば省略名で表示)
$client_name = get_post_meta( $post->bill_client, 'client_short_name', true );
if ( ! $client_name ) {
Expand All @@ -168,13 +178,13 @@ public static function export_csv() {
$c[] = '""'; // 借方補助科目
$c[] = '"対象外"'; // 借方税区分
$c[] = '""'; // 借方部門
$c[] = '"' . $bill_total_add_tax . '"'; // 借方金額(円)
$c[] = '"' . $bill_total_price . '"'; // 借方金額(円)
$c[] = '""'; // 借方税額
$c[] = '"売掛金"'; // 貸方勘定科目
$c[] = '""'; // 貸方補助科目
$c[] = '"対象外"'; // 貸方税区分
$c[] = '""'; // 貸方部門
$c[] = '"' . $bill_total_add_tax . '"'; // 貸方金額(円)
$c[] = '"' . $bill_total_price . '"'; // 貸方金額(円)
$c[] = '""'; // 貸方税額
$c[] = '"[ ' . esc_html( $client_name ) . ' ] ' . esc_html( $post->post_title ) . '"'; // 摘要
$c[] = '""'; // 仕訳メモ
Expand All @@ -189,6 +199,9 @@ public static function export_csv() {
$number ++;
}
}

wp_reset_postdata();

} // if ( $_GET['action'] == 'csv_mf' ){

$full_csv = implode( "\r\n", $csv );
Expand Down
5 changes: 3 additions & 2 deletions inc/template-tags.php
Expand Up @@ -129,8 +129,9 @@ function bill_tax_rate( $post_id ) {
}

// 消費税の指定がない場合
$date = new DateTime( $post->post_date );
$post_date_timestamp = $date->format( 'U' ) . PHP_EOL;
// $date = new DateTime( $post->post_date );
// $post_date_timestamp = $date->format( 'U' ) . PHP_EOL;
$post_date_timestamp = strtotime( $post->post_date );
if ( 1569888000 <= $post_date_timestamp ) {
$rate = 0.1;
} else {
Expand Down
2 changes: 1 addition & 1 deletion style.css
Expand Up @@ -4,7 +4,7 @@ Theme Name: BillVektor
Description:
Author: Vektor,Inc.
Author URI:
Version:1.3.0
Version:1.4.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/

0 comments on commit 9c3aa1b

Please sign in to comment.