Skip to content

Instantly share code, notes, and snippets.

@LiosK
LiosK / 20231207_oci_current_tax.md
Created December 6, 2023 11:57
その他の包括利益における法人税等の会計処理

その他の包括利益における法人税等の会計処理

(この記事は会計系 Advent Calendar 2023の7日目の記事です。)

2022年10月28日に公表された「法人税、住民税及び事業税等に関する会計基準」等の改正によって、その他の包括利益に関連する取引から生じた法人税、住民税及び事業税 (法人税等1) は損益 (PL) ではなくその他の包括利益 (OCI, other comprehensive income) に計上すべきことが日本基準でも明確になりました。

Footnotes

  1. 記事中の「法人税等」と「法人税等調整額」はそれぞれ一貫して当期税金費用と繰延税金費用を指します。当期税金費用・繰延税金費用という語のほうが紛らわしさがなくわかりやすいと個人的には考えていますが、日本の会計実務で一般的に用いられる用語ではないためです。同様に、日本基準に慣れた読者を想定し、IFRSにおける仕訳例でも日本基準で一般的に用いられる勘定科目を便宜的に用いています。

@LiosK
LiosK / divshr.c
Last active August 20, 2023 23:53
A quick benchmark of / and >> in computing millisecond timestamp
#include <stdint.h>
#include <stdio.h>
#include <time.h>
static const long REPEAT = 4;
static const long NUMBER = 400000000;
/// Computes a millisecond timestamp from `struct timespect` components.
#define div(tv_sec, tv_nsec) \
((uint64_t)(tv_sec)*1000 + (uint64_t)(tv_nsec) / 1000000)
use std::{fs, io::Write as _, process};
fn main() {
let _ = rand::random::<u32>(); // initialize ThreadRng
let parent_pid = process::id();
unsafe { nix::unistd::fork() }.expect("fork failed");
let filename = format!("out_{}_{}.txt", parent_pid, process::id());
@LiosK
LiosK / convert_base.rs
Created November 12, 2022 00:52
Converts a digit value array in `src_base` to that in `dst_base`
// XXX NOT TESTED
/// Converts a digit value array in `src_base` to that in `dst_base`.
///
/// # Panics
///
/// Panics if:
///
/// - `src_base` is not between 2 and 256, inclusive;
/// - `dst_base` is not between 2 and 256, inclusive; or,
@LiosK
LiosK / uuidv8_example.c
Last active April 3, 2024 02:11
UUIDv8 Example
#include <stdint.h>
#include <time.h>
int get_random_bytes(uint8_t *buffer, int count);
int generate_uuidv8(uint8_t *uuid, uint8_t node_id) {
struct timespec tp;
if (clock_gettime(CLOCK_REALTIME, &tp) != 0)
return -1; // real-time clock error
/**
* base36_128.h - Base-36 encoder-decoder for 128-bit / 25-digit byte array
*
* Copyright 2022 LiosK
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy
* of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@LiosK
LiosK / base32.mjs
Last active March 8, 2022 04:07
Experimental base36 (modulo) and base32 (bitwise) binary-to-text encoders and decoders
const DIGITS = "0123456789abcdefghijklmnopqrstuv";
/** O(1) map from ASCII code points to digit values. */
const DECODE_MAP = new Uint8Array(128).fill(0xff);
for (let i = 0, uc = DIGITS.toUpperCase(); i < DIGITS.length; i++) {
DECODE_MAP[DIGITS.charCodeAt(i)] = i;
DECODE_MAP[uc.charCodeAt(i)] = i; // omit this to make decoder case-sensitive
}
/** Encodes a byte array to text. */
@LiosK
LiosK / uuidv7.c
Last active November 17, 2023 13:05
Experimental stateless UUIDv7 implementation as of RFC draft 02
/**
* uuidv7.c - Experimental stateless UUIDv7 implementation as of RFC draft 02
*
* Required: `clock_gettime()`, `arc4random_buf()`, and ~15-microseconds or
* finer system clock resolution.
*
* This implementation employs 52-bit timestamp (consisting of 36-bit whole
* seconds and 16-bit sub-second fraction) and 70-bit cryptographically strong
* random integer in the following layout. It does not guarantee the monotonic
* order of the generated IDs within the same timestamp (i.e. within ~15
from datetime import datetime
from secrets import randbits
from typing import Tuple
# In general, the layered approach demonstrates much better collision resistance than
# the naive approach when the per-second randomness field is sufficiently large to
# accommodate a possible number of concurrent generators. Otherwise, the layered
# approach tends to cause burst collisions when the per-second randomness collides.
LEN_PER_SEC = 16
LEN_PER_GEN = 4
@LiosK
LiosK / join_transfer.py
Last active December 23, 2017 14:46
gncxml - join transfer account information if a transaction consists of only two splits
import gncxml
def join_transfer(sp):
pairs = sp.reset_index() \
.groupby(["trn_idtype", "trn_id"]) \
.filter(lambda x: len(x) == 2)
dup = pairs[["trn_idtype", "trn_id", "idtype", "id"]] \
.join(pairs.set_index(["trn_idtype", "trn_id"]) \
.add_prefix("transfer_"), \
on=["trn_idtype", "trn_id"])