implemented

- assigning new customer numbers to contacts that don`t have one
- updating customer number counter in company table

Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
2025-10-31 22:09:59 +01:00
parent dc0b381aba
commit 4468f45064
14 changed files with 157 additions and 20 deletions

View File

@@ -2,7 +2,7 @@
import { onMount } from 'svelte';
import { useTinyRouter } from 'svelte-tiny-router';
import { api } from '../../urls.svelte';
import { api, get } from '../../urls.svelte';
import { error, yikes } from '../../warn.svelte';
import { t } from '../../translations.svelte';
@@ -67,10 +67,21 @@
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.name = addr;
document.customer.tax_id = contact.tax_id;
document.customer.id = contact.customer_number;
document.customer.email = contact.EMAIL;
document.customer.name = addr;
document.customer.tax_id = contact.tax_id;
document.customer.id = contact.customer_number;
document.customer.email = contact.EMAIL;
document.customer.contact_id = contact.id;
if (!document.customer.id) requestNewCustomerId();
}
async function requestNewCustomerId(){
var url = api(`company/${document.sender.company}/next_customer_number`);
var res = await get(url);
yikes();
document.customer.id = await res.text();
if (res.ok){
} else error(res);
}
async function submit(){

View File

@@ -4,6 +4,10 @@ export function api(rel_path){
return `${location.protocol}//${location.host.replace('5173','8080')}/api/${rel_path}`;
}
export function get(url){
return fetch(url,{ credentials:'include' });
}
export function drop(url){
return fetch(url,{
credentials:'include',