import React from 'react';
import Invoice from '../../..';
import idGenerator from '../../../../Invoice/tools/idGenerator';
import 'antd/dist/antd.css';

export default () => {

    const controller = React.useMemo(() => {
        const controller = new Invoice.InvoiceController();
        controller.run(async s => {
            s.model = 'prefab';
            s.goodsListState.goodsList = lines.map(e => {
                return {
                    $index: idGenerator(),
                    ...e,
                }
            });
        }).then(() => {
            controller.formList.get('stakeholder')?.setFieldsValue({
                buyerName: '购买方名称',
                buyerTaxId: 'xxxxxxxxxx',
                buyerAddress: '购买方地址',
                buyerPhone: '15800000000',
                buyerBank: '购买方开户银行',
                buyerAccount: '银行账号',

                supplierName: '销售方名称',
                supplierTaxId: 'xxxxxxxxxxxx',
                sellerAddress: '购买方地址',
                sellerPhone: '15800000000',
                sellerBank: '购买方开户银行',
                sellerAccount: '银行账号',
            })  
        })
        return controller;
    }, []);

    return (
        <Invoice
            invoiceType='digtal'
            controller={controller}
        />
    )
};

const lines: any[] = [
    {
        "buyersItemCode": null,
        "buyersItemModelName": "GN-G32Z104",
        "buyersItemName": "*配电控制设备*公牛(BULL)",
        "buyersItemUnit": null,
        "discount": 5010.04,
        "discountGroup": "31b6d887-4877-4926-abe8-ab49ef6902da",
        "dispatchDocumentReference": null,
        "dispatchLineReference": null,
        "favouredPolicyMark": "0",
        "favouredPolicyName": null,
        "id": "40823568750477313",
        "itemModelName": "GN-G32Z104",
        "itemName": "*配电控制设备*公牛(BULL)",
        "lineAmountExcludeTax": 443365.88,
        "lineAmountIncludeTax": 501003.53,
        "lineAttribute": "0",
        "lineDiscountExcludeTax": 4433.66,
        "lineDiscountRate": null,
        "lineId": "1740823580142206976",
        "lineOrder": 1,
        "materialCode": null,
        "noticeCodeNo": null,
        "noticeLineId": null,
        "orderLineId": null,
        "orderLineReference": null,
        "orderNo": null,
        "orderReference": null,
        "priceExcludeTax": 827.17518997,
        "priceIncludeTax": 934.70796467,
        "quantity": 536,
        "receiptDocumentReference": null,
        "receiptLineReference": null,
        "reconciliationDocumentReference": null,
        "reconciliationSheetLineReference": null,
        "relationReferences": null,
        "requisitionLineNo": null,
        "sellersItemCode": null,
        "sellersItemModelName": null,
        "sellersItemName": "*配电控制设备*1",
        "sellersItemUnit": null,
        "specialManagement": null,
        "statementCode": null,
        "statementLineId": null,
        "taxAmount": 57637.65,
        "taxClassificationCode": "1090407030000000000",
        "taxDiscount": 576.38,
        "taxRate": 13,
        "unit": "件",
        "zeroTaxRateFlag": 'dddddd'
    },
    {
        "buyersItemCode": null,
        "buyersItemModelName": "GN-G32Z104",
        "buyersItemName": "*配电控制设备*公牛(BULL)",
        "buyersItemUnit": null,
        "discount": null,
        "discountGroup": "31b6d887-4877-4926-abe8-ab49ef6902da",
        "dispatchDocumentReference": null,
        "dispatchLineReference": null,
        "favouredPolicyMark": "0",
        "favouredPolicyName": null,
        "id": "40823568750477313",
        "itemModelName": "",
        "itemName": "*配电控制设备*公牛(BULL)",
        "lineAmountExcludeTax": -4433.66,
        "lineAmountIncludeTax": -5010.04,
        "lineAttribute": "0",
        "lineDiscountExcludeTax": null,
        "lineDiscountRate": null,
        "lineId": "1740823580142206976",
        "lineOrder": 2,
        "materialCode": null,
        "noticeCodeNo": null,
        "noticeLineId": null,
        "orderLineId": null,
        "orderLineReference": null,
        "orderNo": null,
        "orderReference": null,
        "priceExcludeTax": null,
        "priceIncludeTax": null,
        "quantity": null,
        "receiptDocumentReference": null,
        "receiptLineReference": null,
        "reconciliationDocumentReference": null,
        "reconciliationSheetLineReference": null,
        "relationReferences": null,
        "requisitionLineNo": null,
        "sellersItemCode": null,
        "sellersItemModelName": null,
        "sellersItemName": "*配电控制设备*1",
        "sellersItemUnit": null,
        "specialManagement": null,
        "statementCode": null,
        "statementLineId": null,
        "taxAmount": -576.38,
        "taxClassificationCode": "1090407030000000000",
        "taxDiscount": null,
        "taxRate": 13,
        "unit": "",
        "zeroTaxRateFlag": null
    }
]

