feat: 结算单预览添加订单数量字段 (#716)
Reviewed-on: daoyoucloud/tachycode#716 Co-authored-by: wjh <wwwjh0710@163.com> Co-committed-by: wjh <wwwjh0710@163.com>
This commit is contained in:
parent
bbf19d31c7
commit
2021230f50
5
.changeset/curly-trees-count.md
Normal file
5
.changeset/curly-trees-count.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@hera/plugin-rental": patch
|
||||
---
|
||||
|
||||
结算单增加订单数量字段
|
@ -179,6 +179,10 @@ export const excelDataHandle = (excelData) => {
|
||||
name: '单位',
|
||||
key: 'name',
|
||||
},
|
||||
{
|
||||
name: '订单数量',
|
||||
key: 'name',
|
||||
},
|
||||
{
|
||||
name: '出入库数量',
|
||||
key: 'name',
|
||||
@ -187,10 +191,6 @@ export const excelDataHandle = (excelData) => {
|
||||
name: '租赁单价',
|
||||
key: 'name',
|
||||
},
|
||||
{
|
||||
name: ' ',
|
||||
key: ' ',
|
||||
},
|
||||
{
|
||||
name: '天日',
|
||||
key: 'name',
|
||||
@ -213,9 +213,9 @@ export const excelDataHandle = (excelData) => {
|
||||
'',
|
||||
category,
|
||||
value.unit_name,
|
||||
parseFloat(value.item_count?.toFixed(2) || 0),
|
||||
parseFloat(value.count.toFixed(2)),
|
||||
parseFloat(value.unit_price.toFixed(5)),
|
||||
'',
|
||||
value.days,
|
||||
parseFloat(value.amount.toFixed(2)),
|
||||
'',
|
||||
@ -248,10 +248,6 @@ export const excelDataHandle = (excelData) => {
|
||||
name: '物质名称',
|
||||
key: 'name',
|
||||
},
|
||||
{
|
||||
name: ' ',
|
||||
key: ' ',
|
||||
},
|
||||
{
|
||||
name: '费用类别',
|
||||
key: 'name',
|
||||
@ -260,6 +256,10 @@ export const excelDataHandle = (excelData) => {
|
||||
name: '单位',
|
||||
key: 'name',
|
||||
},
|
||||
{
|
||||
name: '订单数量',
|
||||
key: 'name',
|
||||
},
|
||||
{
|
||||
name: '出入库数量',
|
||||
key: 'name',
|
||||
@ -284,11 +284,11 @@ export const excelDataHandle = (excelData) => {
|
||||
if (!value.is_excluded) {
|
||||
table3.rows.push([
|
||||
converDate(value.date, 'YYYY-MM-DD'),
|
||||
value.movement === -1 ? '出库' : value.movement === 1 ? '入库' : '出入库',
|
||||
value.movement === '-1' ? '出库' : value.movement === '1' ? '入库' : '出入库',
|
||||
value.name,
|
||||
'',
|
||||
category,
|
||||
value.unit_name,
|
||||
parseFloat(value.item_count?.toFixed(2) || 0),
|
||||
parseFloat(value.count.toFixed(2)),
|
||||
parseFloat(value.unit_price.toFixed(5)),
|
||||
value.days !== 0 ? value.days : '',
|
||||
@ -395,12 +395,12 @@ export const excelDataHandle = (excelData) => {
|
||||
key: ' ',
|
||||
},
|
||||
{
|
||||
name: '结存数量 ',
|
||||
name: '订单数量 ',
|
||||
key: 'name2',
|
||||
},
|
||||
{
|
||||
name: ' ',
|
||||
key: ' ',
|
||||
name: '结存数量 ',
|
||||
key: 'name2',
|
||||
},
|
||||
{
|
||||
name: '物料名称 ',
|
||||
@ -415,12 +415,12 @@ export const excelDataHandle = (excelData) => {
|
||||
key: 'name4',
|
||||
},
|
||||
{
|
||||
name: '结存数量',
|
||||
name: '订单数量',
|
||||
key: 'name5',
|
||||
},
|
||||
{
|
||||
name: ' ',
|
||||
key: ' ',
|
||||
name: '结存数量',
|
||||
key: 'name5',
|
||||
},
|
||||
],
|
||||
rows: [],
|
||||
@ -433,13 +433,13 @@ export const excelDataHandle = (excelData) => {
|
||||
calc.summary[countNum - 1]?.name,
|
||||
'',
|
||||
calc.summary[countNum - 1]?.unit_name,
|
||||
calc.summary[countNum - 1] ? parseFloat(calc.summary[countNum - 1].item_count?.toFixed(2) || 0) : ' ',
|
||||
calc.summary[countNum - 1] ? parseFloat(calc.summary[countNum - 1].count.toFixed(2)) : ' ',
|
||||
'',
|
||||
calc.summary[countNum]?.name ?? '',
|
||||
'',
|
||||
calc.summary[countNum]?.unit_name ?? '',
|
||||
calc.summary[countNum] ? parseFloat(calc.summary[countNum]?.item_count?.toFixed(2) || 0) : '',
|
||||
calc.summary[countNum] ? parseFloat(calc.summary[countNum]?.count.toFixed(2)) : '',
|
||||
'',
|
||||
]);
|
||||
}
|
||||
});
|
||||
@ -611,7 +611,6 @@ export const ExportToExcel = async (data) => {
|
||||
const rows24 = ws.getRows(table2Row, calc.history ? calc.history?.length + 1 : 1);
|
||||
rows24.forEach((value) => {
|
||||
ws.mergeCells(`A${value['_number']}:B${value['_number']}`);
|
||||
ws.mergeCells(`F${value['_number']}:G${value['_number']}`);
|
||||
ws.mergeCells(`I${value['_number']}:J${value['_number']}`);
|
||||
if (value['_number'] !== table2Row) {
|
||||
const row25 = ws.getRow(value['_number']);
|
||||
@ -627,7 +626,6 @@ export const ExportToExcel = async (data) => {
|
||||
excelAddTable(table3Row, '本期明细', ws, table3);
|
||||
const rows37 = ws.getRows(table3Row, calc.list ? calc.list?.length + 1 : 1);
|
||||
rows37.forEach((value) => {
|
||||
ws.mergeCells(`C${value['_number']}:D${value['_number']}`);
|
||||
if (value['_number'] !== table3Row) {
|
||||
const row38 = ws.getRow(value['_number']);
|
||||
row38.alignment = { horizontal: 'right' };
|
||||
@ -663,9 +661,7 @@ export const ExportToExcel = async (data) => {
|
||||
CellBorder(table5Row);
|
||||
rows1?.forEach((value) => {
|
||||
ws.mergeCells(`A${value['_number']}:B${value['_number']}`);
|
||||
ws.mergeCells(`D${value['_number']}:E${value['_number']}`);
|
||||
ws.mergeCells(`F${value['_number']}:G${value['_number']}`);
|
||||
ws.mergeCells(`I${value['_number']}:J${value['_number']}`);
|
||||
if (value['_number'] !== table5Row) {
|
||||
const row38 = ws.getRow(value['_number']);
|
||||
row38.alignment = { horizontal: 'right' };
|
||||
@ -715,6 +711,6 @@ export const ExportToExcel = async (data) => {
|
||||
const blob = new Blob([buffer], {
|
||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
});
|
||||
await saveAs(blob, `${contracts.project?.name}-${calc.name}.xlsx`);
|
||||
await saveAs(blob, `${contracts.name}-${calc.name}.xlsx`);
|
||||
await message.success('导出成功');
|
||||
};
|
||||
|
@ -296,6 +296,7 @@ const PreviewDocument = ({
|
||||
<Text style={[styles.tableCellTitle, styles.cellName]}>物料名称</Text>
|
||||
<Text style={[styles.tableCellTitle, styles.cellCategory]}>费用类别</Text>
|
||||
<Text style={[styles.tableCellTitle, styles.cellUnit]}>单位</Text>
|
||||
<Text style={styles.tableCellTitle}>订单数量</Text>
|
||||
<Text style={styles.tableCellTitle}>出入库数量</Text>
|
||||
<Text style={styles.tableCellTitle}>租赁单价</Text>
|
||||
<Text style={[styles.tableCellTitle, styles.cellDays]}>天日</Text>
|
||||
@ -307,6 +308,7 @@ const PreviewDocument = ({
|
||||
<Text style={[styles.tableCell, styles.cellName]}>{item.name}</Text>
|
||||
<Text style={[styles.tableCell, styles.cellCategory]}>{mapIfHas(getCategory, item.category)}</Text>
|
||||
<Text style={[styles.tableCell, styles.cellUnit]}>{item.unit_name}</Text>
|
||||
<Text style={styles.tableCell}>{formatQuantity(item.item_count, 2)}</Text>
|
||||
<Text style={styles.tableCell}>{formatQuantity(item.count, 2)}</Text>
|
||||
<Text style={styles.tableCell}>{formatCurrency(item.unit_price, 5)}</Text>
|
||||
<Text style={[styles.tableCell, styles.cellDays]}>{item.days}</Text>
|
||||
@ -324,6 +326,7 @@ const PreviewDocument = ({
|
||||
<Text style={[styles.tableCellTitle, styles.cellName]}>物料名称</Text>
|
||||
<Text style={[styles.tableCellTitle, styles.cellCategory]}>费用类别</Text>
|
||||
<Text style={[styles.tableCellTitle, styles.cellUnit]}>单位</Text>
|
||||
<Text style={styles.tableCellTitle}>订单数量</Text>
|
||||
<Text style={styles.tableCellTitle}>出入库数量</Text>
|
||||
<Text style={styles.tableCellTitle}>租赁单价</Text>
|
||||
<Text style={[styles.tableCellTitle, styles.cellDays]}>天日</Text>
|
||||
@ -343,6 +346,7 @@ const PreviewDocument = ({
|
||||
{mapIfHas(getCategory, item.category)}
|
||||
</Text>
|
||||
<Text style={[styles.tableCell, styles.cellUnit]}>{item.unit_name}</Text>
|
||||
<Text style={styles.tableCell}>{formatQuantity(item.item_count, 2)}</Text>
|
||||
<Text style={styles.tableCell}>{formatQuantity(item.count, 2)}</Text>
|
||||
<Text style={styles.tableCell}>{formatCurrency(item.unit_price, 5)}</Text>
|
||||
<Text style={[styles.tableCell, styles.cellDays]}>{item.days !== 0 ? item.days : ''}</Text>
|
||||
@ -360,9 +364,11 @@ const PreviewDocument = ({
|
||||
<View style={styles.tableContentTitle}>
|
||||
<Text style={styles.tableCellTitle}>物料名称</Text>
|
||||
<Text style={styles.tableCellTitle}>单位</Text>
|
||||
<Text style={styles.tableCellTitle}>订单数量</Text>
|
||||
<Text style={styles.tableCellTitle}>结存数量</Text>
|
||||
<Text style={styles.tableCellTitle}>物料名称</Text>
|
||||
<Text style={styles.tableCellTitle}>单位</Text>
|
||||
<Text style={styles.tableCellTitle}>订单数量</Text>
|
||||
<Text style={styles.tableCellTitleLast}>结存数量</Text>
|
||||
</View>
|
||||
{calc.summary?.map((item, index) => {
|
||||
@ -372,11 +378,17 @@ const PreviewDocument = ({
|
||||
<View key={item.name} style={styles.tableContent} wrap={false}>
|
||||
<Text style={styles.tableCell}>{calc.summary[countNum - 1]?.name}</Text>
|
||||
<Text style={styles.tableCell}>{calc.summary[countNum - 1]?.unit_name}</Text>
|
||||
<Text style={styles.tableCell}>
|
||||
{calc.summary[countNum - 1] ? formatQuantity(calc.summary[countNum - 1]?.item_count, 2) : ''}
|
||||
</Text>
|
||||
<Text style={styles.tableCell}>
|
||||
{calc.summary[countNum - 1] ? formatQuantity(calc.summary[countNum - 1]?.count, 2) : ''}
|
||||
</Text>
|
||||
<Text style={styles.tableCell}>{calc.summary[countNum]?.name}</Text>
|
||||
<Text style={styles.tableCell}>{calc.summary[countNum]?.unit_name}</Text>
|
||||
<Text style={styles.tableCell}>
|
||||
{calc.summary[countNum]?.item_count ? formatQuantity(calc.summary[countNum]?.item_count, 2) : ''}
|
||||
</Text>
|
||||
<Text style={styles.tableCellLast}>
|
||||
{calc.summary[countNum]?.count ? formatQuantity(calc.summary[countNum]?.count, 2) : ''}
|
||||
</Text>
|
||||
|
@ -82,9 +82,10 @@ export class SettlementService {
|
||||
!countRule.find((productRule) => productRule.product_id === rule.products[0].product_id);
|
||||
}
|
||||
if (isCount) {
|
||||
const productName = item.record_items.filter(
|
||||
const product = item.record_items.filter(
|
||||
(value) => value.product.product_category.id === recordItem.product_category_id,
|
||||
)[0].product;
|
||||
)[0];
|
||||
const productName = product.product;
|
||||
const day =
|
||||
dayjsDays(item.date) < dayjsDays(settlementAbout.start_date)
|
||||
? getCalcDays(settlementAbout.start_date, settlementAbout.end_date)
|
||||
@ -105,6 +106,7 @@ export class SettlementService {
|
||||
//租赁天数 历史订单就存开始日期到结束日期 当前订单存储订单日期到结束日期
|
||||
days: day,
|
||||
is_excluded: false,
|
||||
item_count: product.count,
|
||||
count: recordItem.weight * Number(movement),
|
||||
unit_price: rule.unit_price * 1000,
|
||||
amount: recordItem.weight * (rule.unit_price * 1000) * day * Number(movement),
|
||||
@ -148,12 +150,13 @@ export class SettlementService {
|
||||
settlement_id: settlementsId, //合同ID
|
||||
movement: item.movement, //出入库状态
|
||||
date: item.date, //时间
|
||||
name: productLength > 1 ? rule.comment ?? '' : recordItem?.product.name, //名称
|
||||
label: productLength > 1 ? rule.comment ?? '' : recordItem?.product.name, //规格
|
||||
name: productLength > 1 ? rule.comment ?? '' : recordItem.product.name, //名称
|
||||
label: productLength > 1 ? rule.comment ?? '' : recordItem.product.name, //规格
|
||||
category: item.category, //费用类别
|
||||
//租赁天数 历史订单就存开始日期到结束日期 当前订单存储订单日期到结束日期
|
||||
days: day,
|
||||
is_excluded: false,
|
||||
item_count: recordItem.count * Number(movement),
|
||||
count: item.weight * Number(movement),
|
||||
unit_price: rule.unit_price * 1000,
|
||||
amount: item.weight * (rule.unit_price * 1000) * day * Number(movement),
|
||||
@ -198,6 +201,7 @@ export class SettlementService {
|
||||
const { count, unit } = ruleCount(rule, item, recordItem);
|
||||
data['unit_name'] = unit;
|
||||
data['count'] = count * Number(movement);
|
||||
data['item_count'] = recordItem.count * Number(movement);
|
||||
data['unit_price'] = price;
|
||||
data['amount'] = data['count'] * price * (data.days || 0);
|
||||
createLeasDatas.push(data);
|
||||
@ -284,6 +288,7 @@ export class SettlementService {
|
||||
label: recordItem.product.label + '-' + spec,
|
||||
category: name,
|
||||
movement: item.movement,
|
||||
item_count: value.count,
|
||||
count: count,
|
||||
unit_price: rulefee.unit_price,
|
||||
amount: rulefee.unit_price * count,
|
||||
@ -310,6 +315,7 @@ export class SettlementService {
|
||||
label: recordItem.product.label + '-' + spec,
|
||||
category: name,
|
||||
movement: '-1',
|
||||
item_count: recordItem.count,
|
||||
count: recordCount,
|
||||
unit_price: rulefee.unit_price,
|
||||
amount: count * rulefee.unit_price,
|
||||
@ -334,6 +340,7 @@ export class SettlementService {
|
||||
category: name,
|
||||
movement: '1',
|
||||
count: recordCount,
|
||||
item_count: recordItem.count,
|
||||
unit_price: rulefee.unit_price,
|
||||
amount: count * rulefee.unit_price,
|
||||
unit_name: unit,
|
||||
@ -356,6 +363,7 @@ export class SettlementService {
|
||||
category: name,
|
||||
movement: '0',
|
||||
count: recordCount,
|
||||
item_count: recordItem.count,
|
||||
unit_price: rule.unit_price,
|
||||
amount: count * rule.unit_price,
|
||||
unit_name: unit,
|
||||
@ -390,6 +398,7 @@ export class SettlementService {
|
||||
category: name,
|
||||
movement: '0',
|
||||
count: 0,
|
||||
item_count: 0,
|
||||
unit_price: rule.unit_price,
|
||||
amount: 0,
|
||||
unit_name: rule.unit,
|
||||
@ -411,6 +420,7 @@ export class SettlementService {
|
||||
}, 0)
|
||||
: 0
|
||||
: item.weight;
|
||||
|
||||
if (item.fee_item.length) {
|
||||
item.fee_item.forEach((value) => {
|
||||
if (value.product_id === rule.fee_product_id) {
|
||||
@ -586,6 +596,7 @@ export class SettlementService {
|
||||
) {
|
||||
data.count = data.count / 1000;
|
||||
}
|
||||
data.item_count = data.count;
|
||||
data.amount = data.count * data.unit_price;
|
||||
createFeesDatas.push(data);
|
||||
}
|
||||
@ -622,6 +633,7 @@ export class SettlementService {
|
||||
summaryCategoryItems.push({
|
||||
settlement_id: settlementsId,
|
||||
name: item.name,
|
||||
item_count: item.item_count,
|
||||
count: item.count,
|
||||
unit_name: item.unit_name,
|
||||
type: 'category',
|
||||
@ -630,6 +642,7 @@ export class SettlementService {
|
||||
summaryCategoryItems.forEach((value) => {
|
||||
if (value.name === item.name) {
|
||||
value.count += item.count;
|
||||
value.item_count += item.item_count;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -644,12 +657,14 @@ export class SettlementService {
|
||||
name: item.name,
|
||||
count: item.count,
|
||||
unit_name: item.unit_name,
|
||||
item_count: item.item_count,
|
||||
type: 'product',
|
||||
});
|
||||
} else {
|
||||
summaryProductItems.forEach((value) => {
|
||||
if (value.name === item.name) {
|
||||
value.count += item.count;
|
||||
value.item_count += item.item_count;
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -833,9 +848,10 @@ const recordWeight = (rule, item, settlementsId, productRule, rulefee?) => {
|
||||
productRule.product_id - RulesNumber === weightItem.product_category_id) ||
|
||||
productRule.product_id === weightItem.product_category_id,
|
||||
)[0];
|
||||
const productsName = item.record_items?.filter(
|
||||
const product = item.record_items?.filter(
|
||||
(value) => value.product.category_id === itemWeight.product_category_id,
|
||||
)[0].product;
|
||||
)[0];
|
||||
const productsName = product.product;
|
||||
const productName = productCategory === 'category' ? productsName.name : productsName.label;
|
||||
return {
|
||||
settlement_id: settlementsId,
|
||||
@ -846,6 +862,7 @@ const recordWeight = (rule, item, settlementsId, productRule, rulefee?) => {
|
||||
movement: item.movement,
|
||||
count: itemWeight.weight,
|
||||
unit_price: rulefee.unit_price,
|
||||
item_count: product.count,
|
||||
amount: itemWeight.weight * rulefee.unit_price,
|
||||
unit_name: '吨',
|
||||
is_excluded: false,
|
||||
@ -875,6 +892,7 @@ const recordWeight = (rule, item, settlementsId, productRule, rulefee?) => {
|
||||
label: productName + '-' + spec,
|
||||
category: name,
|
||||
movement: item.movement,
|
||||
item_count: isRecordItem.count,
|
||||
count: count,
|
||||
unit_price: rulefee.unit_price,
|
||||
amount: item.weight * rulefee.unit_price,
|
||||
@ -1028,6 +1046,7 @@ const feeData = (data, settlementAbout: Settlement, type) => {
|
||||
count: value.count,
|
||||
days: 0,
|
||||
name: name,
|
||||
item_count: value.item_count,
|
||||
unit_name: value.unit_name,
|
||||
unit_price: value.unit_price,
|
||||
is_excluded: value.is_excluded,
|
||||
@ -1036,6 +1055,7 @@ const feeData = (data, settlementAbout: Settlement, type) => {
|
||||
} else {
|
||||
feeItem[listKey].count = feeItem[listKey].count + value.count;
|
||||
feeItem[listKey].amount = feeItem[listKey].amount + value.amount;
|
||||
feeItem[listKey].item_count = feeItem[listKey].item_count + value.item_count;
|
||||
feeItem[listKey].unit_price = isNaN(feeItem[listKey].amount / feeItem[listKey].count)
|
||||
? 0
|
||||
: feeItem[listKey].amount / feeItem[listKey].count;
|
||||
@ -1109,6 +1129,7 @@ const screenData = (data, settlementAbout, type) => {
|
||||
name: name,
|
||||
unit_name: value.unit_name,
|
||||
unit_price: value.unit_price,
|
||||
item_count: value.item_count,
|
||||
is_excluded: value.is_excluded,
|
||||
type: type,
|
||||
};
|
||||
@ -1117,6 +1138,7 @@ const screenData = (data, settlementAbout, type) => {
|
||||
history[historyKey].amount = formatNumber(history[historyKey].amount) + formatNumber(value.amount);
|
||||
history[historyKey].unit_price =
|
||||
history[historyKey].amount / history[historyKey].count / history[historyKey].days;
|
||||
history[historyKey].item_count = formatNumber(history[historyKey].item_count) + formatNumber(value.item_count);
|
||||
}
|
||||
} else {
|
||||
if (!list[listKey]) {
|
||||
@ -1130,6 +1152,7 @@ const screenData = (data, settlementAbout, type) => {
|
||||
days: value.days,
|
||||
name: name,
|
||||
unit_name: value.unit_name,
|
||||
item_count: value.item_count,
|
||||
unit_price: value.unit_price,
|
||||
is_excluded: value.is_excluded,
|
||||
type: type,
|
||||
@ -1140,6 +1163,7 @@ const screenData = (data, settlementAbout, type) => {
|
||||
list[listKey].unit_price = isNaN(list[listKey].amount / list[listKey].count / list[listKey].days)
|
||||
? 0
|
||||
: list[listKey].amount / list[listKey].count / list[listKey].days;
|
||||
list[listKey].item_count = formatNumber(list[listKey].item_count) + formatNumber(value.item_count);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user