implemented document creation
this required a major refactoring of the object model
This commit is contained in:
@@ -9,13 +9,13 @@
|
||||
let error = null;
|
||||
let docType = $state(null);
|
||||
let document = $state({
|
||||
type : router.query.document_type,
|
||||
company : router.query.company_id,
|
||||
type : +router.query.document_type,
|
||||
customer : {
|
||||
addr : ''
|
||||
name : ''
|
||||
},
|
||||
sender : {
|
||||
name : 'sender'
|
||||
name : 'sender',
|
||||
company : +router.query.company_id
|
||||
}
|
||||
});
|
||||
|
||||
@@ -24,13 +24,13 @@
|
||||
var resp = await fetch(url,{ credentials: 'include'});
|
||||
if (resp.ok){
|
||||
const companies = await resp.json();
|
||||
company = companies[document.company];
|
||||
company = companies[document.sender.company];
|
||||
document.sender.name = '';
|
||||
if (company.name) document.sender.name += company.name+"\n";
|
||||
if (company.address) document.sender.name += company.address+"\n";
|
||||
if (company.tax_number) document.sender.tax_id = company.tax_number;
|
||||
if (company.name) document.sender.name += company.name+"\n";
|
||||
if (company.address) document.sender.name += company.address+"\n";
|
||||
if (company.tax_number) document.sender.tax_id = company.tax_number;
|
||||
if (company.bank_account) document.sender.bank_account = company.bank_account;
|
||||
if (company.court) document.sender.court = company.court;
|
||||
if (company.court) document.sender.court = company.court;
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
@@ -59,13 +59,13 @@
|
||||
var name = (contact.N.given+" "+contact.N.family).trim()+"\n";
|
||||
if (name != addr) addr += name;
|
||||
}
|
||||
if (contact.ADR.street) addr += contact.ADR.street+"\n";
|
||||
if (contact.ADR.street) addr += contact.ADR.street+"\n";
|
||||
if (contact.ADR.locality) addr += contact.ADR.post_code + " "+ contact.ADR.locality + "\n";
|
||||
if (contact.ADR.county) addr += contact.ADR.country+"\n";
|
||||
document.customer.addr = addr;
|
||||
document.customer.tax_number = contact['X-TAX-NUMBER'];
|
||||
document.customer.id = contact['X-CUSTOMER-NUMBER'];
|
||||
document.customer.email = contact.EMAIL.val;
|
||||
if (contact.ADR.county) addr += contact.ADR.country+"\n";
|
||||
document.customer.name = addr;
|
||||
document.customer.tax_id = contact['X-TAX-NUMBER'];
|
||||
document.customer.id = contact['X-CUSTOMER-NUMBER'];
|
||||
document.customer.email = contact.EMAIL.val;
|
||||
}
|
||||
|
||||
async function submit(){
|
||||
@@ -76,6 +76,8 @@
|
||||
body: JSON.stringify(document)
|
||||
});
|
||||
if (resp.ok){
|
||||
const json = await resp.json();
|
||||
router.navigate(`/document/${json.id}/view`);
|
||||
} else {
|
||||
error = await resp.text();
|
||||
}
|
||||
@@ -101,12 +103,12 @@
|
||||
<legend>{t('document.customer')}</legend>
|
||||
<ContactSelector caption={t('document.select_customer')} onselect={contactSelected} />
|
||||
<label>
|
||||
<textarea bind:value={document.customer.addr}></textarea>
|
||||
<textarea bind:value={document.customer.name}></textarea>
|
||||
{t('document.customer_address')}
|
||||
</label>
|
||||
<label>
|
||||
<input bind:value={document.customer.tax_number} />
|
||||
{t('document.tax_number')}
|
||||
<input bind:value={document.customer.tax_id} />
|
||||
{t('document.tax_id')}
|
||||
</label>
|
||||
<label>
|
||||
<input bind:value={document.customer.id} />
|
||||
|
||||
Reference in New Issue
Block a user