fix: 合同添加甲乙字段并同步对账单 (#1505)
Co-authored-by: TomyJan <tomyjan6@gmail.com> Reviewed-on: daoyoucloud/tachybase#1505 Co-authored-by: wjh <wwwjh0710@163.com> Co-committed-by: wjh <wwwjh0710@163.com>
This commit is contained in:
parent
2942be453f
commit
94c030e133
@ -9,6 +9,7 @@ import { converDate } from '../../../utils/daysUtils';
|
|||||||
|
|
||||||
export const excelDataHandle = (excelData) => {
|
export const excelDataHandle = (excelData) => {
|
||||||
const { calc, contracts, result } = excelData;
|
const { calc, contracts, result } = excelData;
|
||||||
|
const partyB = contracts.partyB?.[0];
|
||||||
const categoryCount = (itemCategory) => {
|
const categoryCount = (itemCategory) => {
|
||||||
let category = '';
|
let category = '';
|
||||||
switch (itemCategory) {
|
switch (itemCategory) {
|
||||||
@ -57,7 +58,7 @@ export const excelDataHandle = (excelData) => {
|
|||||||
*/
|
*/
|
||||||
const nameRows = [
|
const nameRows = [
|
||||||
{
|
{
|
||||||
companyName: { name: '承租单位:', value: `${contracts.project?.company?.name ?? ''}` },
|
companyName: { name: '承租单位:', value: `${partyB?.name ?? ''}` },
|
||||||
companyName1: { name: '合同编号:', value: `${contracts.project?.code ?? ''}` },
|
companyName1: { name: '合同编号:', value: `${contracts.project?.code ?? ''}` },
|
||||||
rowId: '3',
|
rowId: '3',
|
||||||
},
|
},
|
||||||
@ -573,9 +574,7 @@ export const ExportToExcel = async (data) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
//设置表格表头
|
//设置表格表头
|
||||||
ws.getCell('A1').value = `${
|
ws.getCell('A1').value = `${contracts.partyA?.[0]?.name ?? `${PromptText.noContractedCompany}`} 对账单`;
|
||||||
contracts.project?.associated_company?.name ?? `${PromptText.noContractedCompany}`
|
|
||||||
} 对账单`;
|
|
||||||
ws.mergeCells('A1:J1');
|
ws.mergeCells('A1:J1');
|
||||||
ws.getCell('A1').alignment = { vertical: 'middle', horizontal: 'center' };
|
ws.getCell('A1').alignment = { vertical: 'middle', horizontal: 'center' };
|
||||||
ws.getCell('A1').font = {
|
ws.getCell('A1').font = {
|
||||||
@ -687,7 +686,7 @@ export const ExportToExcel = async (data) => {
|
|||||||
contracts.project?.associated_company.address;
|
contracts.project?.associated_company.address;
|
||||||
ws.getCell(`F${notesRow}`).value = `
|
ws.getCell(`F${notesRow}`).value = `
|
||||||
备注:${contracts.project?.comment ?? ''}
|
备注:${contracts.project?.comment ?? ''}
|
||||||
出租单位:${contracts.project?.associated_company?.name ?? PromptText.noContractedCompany}`;
|
出租单位:${contracts.partyA?.[0]?.name ?? PromptText.noContractedCompany}`;
|
||||||
ws.mergeCells(`F${notesRow}:J${notesRow}`);
|
ws.mergeCells(`F${notesRow}:J${notesRow}`);
|
||||||
const url = 'http://985.so/bpw6g';
|
const url = 'http://985.so/bpw6g';
|
||||||
const imageUrl = await QRCode.toDataURL(url);
|
const imageUrl = await QRCode.toDataURL(url);
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
import { Migration } from '@tachybase/server';
|
||||||
|
|
||||||
|
export default class extends Migration {
|
||||||
|
on = 'beforeLoad'; // 'beforeLoad' or 'afterLoad'
|
||||||
|
appVersion = '<0.21.88';
|
||||||
|
async up() {
|
||||||
|
const result: any = await this.app.db.sequelize.query(`
|
||||||
|
UPDATE contracts
|
||||||
|
SET
|
||||||
|
"partyAId" = b.associated_company_id,
|
||||||
|
"partyBId" = b.company_id
|
||||||
|
FROM project b
|
||||||
|
WHERE
|
||||||
|
b.id = CASE
|
||||||
|
WHEN contracts.project_id IS NOT NULL
|
||||||
|
THEN contracts.project_id
|
||||||
|
ELSE (
|
||||||
|
SELECT c.project_id
|
||||||
|
FROM contracts c
|
||||||
|
WHERE c.id = contracts.alternative_contract_id
|
||||||
|
)
|
||||||
|
END
|
||||||
|
`);
|
||||||
|
const count = result[1].rowCount || 0;
|
||||||
|
console.log('共更新数据:' + count + '条');
|
||||||
|
}
|
||||||
|
}
|
@ -220,11 +220,14 @@ const PreviewDocument = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const partyA = contracts.partyA?.[0];
|
||||||
|
const partyB = contracts.partyB?.[0];
|
||||||
return (
|
return (
|
||||||
<Document>
|
<Document>
|
||||||
<Page size="A4" style={styles.page}>
|
<Page size="A4" style={styles.page}>
|
||||||
<Text style={styles.title}>
|
<Text style={styles.title}>
|
||||||
{contracts.project?.associated_company?.name ?? `${PromptText.noContractedCompany}`}
|
{partyA?.name ?? `${PromptText.noContractedCompany}`}
|
||||||
对账单
|
对账单
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={styles.subTitle}>客户各项费用明细</Text>
|
<Text style={styles.subTitle}>客户各项费用明细</Text>
|
||||||
@ -233,7 +236,7 @@ const PreviewDocument = ({
|
|||||||
<View style={styles.tableHeader}>
|
<View style={styles.tableHeader}>
|
||||||
<Text style={styles.headerLeft}>
|
<Text style={styles.headerLeft}>
|
||||||
承租单位:
|
承租单位:
|
||||||
{contracts?.project?.company?.name}
|
{partyB?.name}
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={styles.headerRight}>
|
<Text style={styles.headerRight}>
|
||||||
合同编号:
|
合同编号:
|
||||||
@ -416,7 +419,7 @@ const PreviewDocument = ({
|
|||||||
<Text>备注:{contracts.project?.comment}</Text>
|
<Text>备注:{contracts.project?.comment}</Text>
|
||||||
<Text>
|
<Text>
|
||||||
出租单位:
|
出租单位:
|
||||||
{contracts.project?.associated_company?.name ?? `${PromptText.noContractedCompany}`}
|
{partyA?.name ?? `${PromptText.noContractedCompany}`}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
@ -59,6 +59,30 @@ SELECT
|
|||||||
WHERE
|
WHERE
|
||||||
c3.id = settlements.contract_id
|
c3.id = settlements.contract_id
|
||||||
)
|
)
|
||||||
|
) || JSONB_SET(
|
||||||
|
TO_JSONB(contracts),
|
||||||
|
'{partyA}',
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
COALESCE(JSONB_AGG(companyA), '{}'::jsonb)
|
||||||
|
FROM
|
||||||
|
company companyA
|
||||||
|
JOIN contracts c4 ON c4."partyAId" = companyA.id
|
||||||
|
WHERE
|
||||||
|
c4.id = settlements.contract_id
|
||||||
|
)
|
||||||
|
) || JSONB_SET(
|
||||||
|
TO_JSONB(contracts),
|
||||||
|
'{partyB}',
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
COALESCE(JSONB_AGG(companyB), '{}'::jsonb)
|
||||||
|
FROM
|
||||||
|
company companyB
|
||||||
|
JOIN contracts c4 ON c4."partyBId" = companyB.id
|
||||||
|
WHERE
|
||||||
|
c4.id = settlements.contract_id
|
||||||
|
)
|
||||||
)
|
)
|
||||||
) AS contracts,
|
) AS contracts,
|
||||||
(
|
(
|
||||||
|
Loading…
Reference in New Issue
Block a user