1. 【新增】售后单售后原因类型支持搜索

2. 【新增】手工创建订单折扣可输入正数

3. 【优化】盘点申请单确认

4. 【修复】采购退货单模拟出库失败问题

5. 【新增】订单金额客户实付与结算金额

6. 【优化】仓库发货统计报表物料名称显示

7. 【优化】自有仓储虚拟发货逻辑

8. 【修复】基础物料分类管理问题
This commit is contained in:
chenping
2026-04-01 11:59:17 +08:00
parent 9341122827
commit 61783b7d01
754 changed files with 46179 additions and 5700 deletions

View File

@@ -116,11 +116,72 @@ abstract class financebase_expenses_sku_abstract {
$className = explode('_', $className);
$this->type = $className[2];
$this->rule = $className[3];
$expensesSplitModel = app::get('financebase')->model('expenses_split');
$this->_dealCombinationItems($skuList);
$porth = $this->_getPorthValue($skuList);
if(empty($porth)) {
return array(false, $this->failMsg);
}
// 获取会计科目和税率信息
$accountInfo = array(
'account_id_plus' => null,
'account_id_minus' => null,
'tax_rate_plus' => 0,
'tax_rate_minus' => 0,
'postingkey_plus' => '',
'postingkey_minus' => '',
'costcenter_plus' => '',
'costcenter_minus' => '',
'customer_plus' => '',
'customer_minus' => '',
);
if (!empty($skuList['bill']['bill_category'])) {
$ruleModel = app::get('financebase')->model('expenses_rule');
$ruleData = $ruleModel->db_dump(
array('bill_category' => $skuList['bill']['bill_category']),
'account_id_plus,account_id_minus'
);
if ($ruleData) {
$accountInfo['account_id_plus'] = $ruleData['account_id_plus'];
$accountInfo['account_id_minus'] = $ruleData['account_id_minus'];
$accountChartModel = app::get('financebase')->model('account_chart');
// 如果有贷会计科目,获取税率、记账码、成本中心、客户信息
if ($ruleData['account_id_plus']) {
$accountData = $accountChartModel->db_dump(
array('id' => $ruleData['account_id_plus']),
'tax_rate,postingkey,costcenter,customer'
);
if ($accountData) {
if ($accountData['tax_rate']) {
$accountInfo['tax_rate_plus'] = $accountData['tax_rate'];
}
$accountInfo['postingkey_plus'] = $accountData['postingkey'] ?? '';
$accountInfo['costcenter_plus'] = $accountData['costcenter'] ?? '';
$accountInfo['customer_plus'] = $accountData['customer'] ?? '';
}
}
// 如果有借会计科目,获取税率、记账码、成本中心、客户信息
if ($ruleData['account_id_minus']) {
$accountData = $accountChartModel->db_dump(
array('id' => $ruleData['account_id_minus']),
'tax_rate,postingkey,costcenter,customer'
);
if ($accountData) {
if ($accountData['tax_rate']) {
$accountInfo['tax_rate_minus'] = $accountData['tax_rate'];
}
$accountInfo['postingkey_minus'] = $accountData['postingkey'] ?? '';
$accountInfo['costcenter_minus'] = $accountData['costcenter'] ?? '';
$accountInfo['customer_minus'] = $accountData['customer'] ?? '';
}
}
}
}
$time = $time ? : time();
$expensesSplit = array();
$hasPorth = false;
@@ -129,6 +190,7 @@ abstract class financebase_expenses_sku_abstract {
$hasPorth = true;
}
$expensesSplit[] = array(
'split_bn' => $expensesSplitModel->gen_id(),
'bm_id' => $v['bm_id'],
'bill_id' => $skuList['bill']['id'],
'parent_id' => $skuList['parent_id'],
@@ -141,13 +203,26 @@ abstract class financebase_expenses_sku_abstract {
'split_rule' => $this->rule,
'porth' => $porth[$v['bm_id']],
'shop_id' => $skuList['bill']['shop_id'],
'account_id_plus' => $accountInfo['account_id_plus'],
'account_id_minus' => $accountInfo['account_id_minus'],
'tax_rate_plus' => $accountInfo['tax_rate_plus'],
'tax_rate_minus' => $accountInfo['tax_rate_minus'],
'tax_amount_plus' => 0, // 将在计算money后更新
'tax_amount_minus' => 0, // 将在计算money后更新
'order_bn' => $skuList['bill']['order_bn'] ?? '',
'financial_no' => $skuList['bill']['financial_no'] ?? '',
'postingkey_plus' => $accountInfo['postingkey_plus'],
'postingkey_minus' => $accountInfo['postingkey_minus'],
'costcenter_plus' => $accountInfo['costcenter_plus'],
'costcenter_minus' => $accountInfo['costcenter_minus'],
'customer_plus' => $accountInfo['customer_plus'],
'customer_minus' => $accountInfo['customer_minus'],
);
}
if(!$hasPorth) {
return array(false, $this->failMsg);
}
if($skuList['ids']) {
$expensesSplitModel = app::get('financebase')->model('expenses_split');
$olds = $expensesSplitModel->db_dump(['bill_id'=>$skuList['bill']['id']]);
try{
$splitStatus = $olds ? '2' : '1';
@@ -160,7 +235,20 @@ abstract class financebase_expenses_sku_abstract {
'porth_field' => 'porth',
);
$expensesSplit = kernel::single('ome_order')->calculate_part_porth($expensesSplit, $options, 5);
$expensesSplitModel = app::get('financebase')->model('expenses_split');
// 计算税金
foreach ($expensesSplit as &$item) {
// 计算贷方税金
if ($accountInfo['tax_rate_plus'] > 0) {
$item['tax_amount_plus'] = round($item['money'] * $accountInfo['tax_rate_plus'], 5);
}
// 计算借方税金
if ($accountInfo['tax_rate_minus'] > 0) {
$item['tax_amount_minus'] = round($item['money'] * $accountInfo['tax_rate_minus'], 5);
}
}
unset($item);
$sql = ome_func::get_insert_sql($expensesSplitModel, $expensesSplit);
$expensesSplitModel->db->exec($sql);
return array(true, '拆分完成');

View File

@@ -0,0 +1,69 @@
<?php
class financebase_expenses_split_import {
const IMPORT_TITLE = [
'拆分单号' => 'split_bn',
'是否已记账' => 'is_accounted',
];
public function getExcelTitle()
{
return ['费用拆分记账导入模板.xlsx',[
array_keys(self::IMPORT_TITLE)
]];
}
/**
* 处理Excel导入行数据
*
* @param string $import_file 导入文件路径
* @param array $post 提交参数
* @return array
* @author
**/
public function processExcelRow($import_file, $post)
{
$format = [];
// 读取文件
return kernel::single('omecsv_phpoffice')->import($import_file, function ($line, $buffer, $post, $highestRow) {
static $title;
if ($line == 1) {
$title = $buffer;
// 验证模板是否正确
if (array_filter($title) != array_keys(self::IMPORT_TITLE)) {
return [false, '导入模板不正确'];
}
return [true];
}
// 将Excel行数据转换为关联数组
$buffer = array_combine(self::IMPORT_TITLE, array_slice($buffer, 0, count(self::IMPORT_TITLE)));
if (empty($buffer['is_accounted'])) {
return [false, '“是否已记账”字段不能为空'];
}
if (empty($buffer['split_bn'])) {
return [false, '“拆分单号”字段不能为空'];
}
$buffer['is_accounted'] = $buffer['is_accounted'] == '是' ? '1' : '0';
$expensesSplitModel = app::get('financebase')->model('expenses_split');
$existRow = $expensesSplitModel->db_dump(['split_bn' => $buffer['split_bn']], 'id');
if (!$existRow) {
return [false, '拆分单号不存在:' . $buffer['split_bn']];
}
$updateData = [
'is_accounted' => $buffer['is_accounted'],
];
// 如果已记账,记录记账时间
if ($buffer['is_accounted'] == '1') {
$updateData['accounted_time'] = time();
} else {
// 如果未记账将记账时间设置为0
$updateData['accounted_time'] = 0;
}
$expensesSplitModel->update($updateData, ['id' => $existRow['id']]);
return [true];
}, $post, $format);
}
}