francescotrucchia/cashflow 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

francescotrucchia/cashflow

Composer 安装命令:

composer require francescotrucchia/cashflow

包简介

Library to manage cashflow

README 文档

README

Cashflow library is a set of php classes useful for manage cashflow operation as income, outcome and recurrent entries.

<?php

require_once __DIR__.'/../vendor/autoload.php';

use Cashflow\Cashflow;
use Cashflow\Outcome;
use Cashflow\Income;

$entries = [
    [new \Cashflow\Income(),  new \DateTime(date('Y/06/10')), 'Balance', 1000],
    [new \Cashflow\Expense(), new \DateTime(date('Y/06/11')), 'Credit card', 100],
    [new \Cashflow\Recurrent(new \Cashflow\Income()),  new \DateTime(date('Y/1/10')), 'Salary', 1500, new \DateInterval('P1M'), new \DateTime(date('Y/12/31'))],
    [new \Cashflow\Recurrent(new \Cashflow\Expense()),  new \DateTime(date('Y/1/12')), 'Rent', 500, new \DateInterval('P1M'), new \DateTime(date('Y/12/31'))],
];

$cashflow = new Cashflow(new \DateTime(date('Y/1/1')), new \DateTime(date('Y/12/30')));
$cashflow->import($entries);
$cashflow->order();
    
$mask = "|%-10.10s |%-30.30s |%15s |%15s |\n";

$output = sprintf($mask, 'Date', 'Name', 'Flow', 'Balance');

foreach($cashflow->getRows() as $row){
    $cashflow->updateAmount($row, $row->getSign());
    $output .= sprintf(
        $mask, 
        $row->getDate()->format('Y-m-d'), 
        $row->getName(), 
        $row->getSign()*$row->getAmount(), 
        $cashflow->getAmount()
    );
}

$output .= PHP_EOL.
  sprintf('Total income: %s'.PHP_EOL, money_format('%.2n', $cashflow->getTotaleIncome())).
  sprintf('Total expense: %s'.PHP_EOL, money_format('%.2n', $cashflow->getTotalExpense())).
  sprintf('Profit: %s'.PHP_EOL, money_format('%.2n', $cashflow->getBalance()));

echo $output;

统计信息

  • 总下载量: 36
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 0
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固