fix bugs and stripe
This commit is contained in:
parent
9a7e3fe740
commit
21a256a26f
17 changed files with 542 additions and 88 deletions
|
|
@ -318,9 +318,9 @@ const handleSubmit = async () => {
|
|||
const createdClient = await Api.createClient(client.value);
|
||||
console.log("Created client:", createdClient);
|
||||
notificationStore.addSuccess("Client created successfully!");
|
||||
stripped_name = createdClient.customerName.split("-#-")[0].trim();
|
||||
const strippedName = createdClient.name.split("-#-")[0].trim();
|
||||
// Navigate to the created client
|
||||
router.push('/client?client=' + encodeURIComponent(stripped_name));
|
||||
router.push('/client?client=' + encodeURIComponent(strippedName));
|
||||
} else {
|
||||
// TODO: Implement save logic
|
||||
notificationStore.addSuccess("Changes saved successfully!");
|
||||
|
|
|
|||
|
|
@ -926,6 +926,11 @@ watch(
|
|||
|
||||
formData.projectTemplate = estimate.value.customProjectTemplate || estimate.value.custom_project_template || null;
|
||||
|
||||
// Load quotation items if project template is set (needed for item details)
|
||||
if (formData.projectTemplate) {
|
||||
quotationItems.value = await Api.getQuotationItems(formData.projectTemplate);
|
||||
}
|
||||
|
||||
if (estimate.value.items && estimate.value.items.length > 0) {
|
||||
selectedItems.value = estimate.value.items.map(item => {
|
||||
const fullItem = quotationItems.value.find(qi => qi.itemCode === item.itemCode);
|
||||
|
|
@ -967,6 +972,10 @@ watch(
|
|||
try {
|
||||
bidMeeting.value = await Api.getBidMeeting(newFromMeetingQuery);
|
||||
if (bidMeeting.value?.bidNotes?.quantities) {
|
||||
// Ensure quotationItems is an array before using find
|
||||
if (!Array.isArray(quotationItems.value)) {
|
||||
quotationItems.value = [];
|
||||
}
|
||||
selectedItems.value = bidMeeting.value.bidNotes.quantities.map(q => {
|
||||
const item = quotationItems.value.find(i => i.itemCode === q.item);
|
||||
return {
|
||||
|
|
@ -1014,6 +1023,10 @@ onMounted(async () => {
|
|||
bidMeeting.value = await Api.getBidMeeting(fromMeetingQuery.value);
|
||||
// If new estimate and bid notes have quantities, set default items
|
||||
if (isNew.value && bidMeeting.value?.bidNotes?.quantities) {
|
||||
// Ensure quotationItems is an array before using find
|
||||
if (!Array.isArray(quotationItems.value)) {
|
||||
quotationItems.value = [];
|
||||
}
|
||||
selectedItems.value = bidMeeting.value.bidNotes.quantities.map(q => {
|
||||
const item = quotationItems.value.find(i => i.itemCode === q.item);
|
||||
return {
|
||||
|
|
@ -1069,18 +1082,26 @@ onMounted(async () => {
|
|||
|
||||
formData.projectTemplate = estimate.value.customProjectTemplate || estimate.value.custom_project_template || null;
|
||||
|
||||
// Load quotation items if project template is set (needed for item details)
|
||||
if (formData.projectTemplate) {
|
||||
quotationItems.value = await Api.getQuotationItems(formData.projectTemplate);
|
||||
}
|
||||
// Ensure quotationItems is an array
|
||||
if (!Array.isArray(quotationItems.value)) {
|
||||
quotationItems.value = [];
|
||||
}
|
||||
|
||||
// Populate items from the estimate
|
||||
if (estimate.value.items && estimate.value.items.length > 0) {
|
||||
selectedItems.value = estimate.value.items.map(item => {
|
||||
// Find the full item details from quotationItems
|
||||
const fullItem = quotationItems.value.find(qi => qi.itemCode === item.itemCode);
|
||||
const discountPercentage = item.discountPercentage || item.discount_percentage || 0;
|
||||
const discountAmount = item.discountAmount || item.discount_amount || 0;
|
||||
return {
|
||||
itemCode: item.itemCode,
|
||||
itemName: item.itemName,
|
||||
itemCode: item.itemCode || item.item_code,
|
||||
itemName: item.itemName || item.item_name,
|
||||
qty: item.qty,
|
||||
standardRate: item.rate || fullItem?.standardRate || 0,
|
||||
rate: item.rate,
|
||||
standardRate: item.rate,
|
||||
discountAmount: discountAmount === 0 ? null : discountAmount,
|
||||
discountPercentage: discountPercentage === 0 ? null : discountPercentage,
|
||||
discountType: discountPercentage > 0 ? 'percentage' : 'currency'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue