mirror of
https://github.com/frappe/books.git
synced 2025-02-02 12:08:27 +00:00
feat: save return invoices in POS
This commit is contained in:
parent
1609027706
commit
95bfa4d9ff
@ -50,6 +50,7 @@ import { CouponCode } from '../CouponCode/CouponCode';
|
||||
import { SalesInvoice } from '../SalesInvoice/SalesInvoice';
|
||||
import { SalesInvoiceItem } from '../SalesInvoiceItem/SalesInvoiceItem';
|
||||
import { PricingRuleItem } from '../PricingRuleItem/PricingRuleItem';
|
||||
import { getLinkedEntries } from 'src/utils/doc';
|
||||
|
||||
export type TaxDetail = {
|
||||
account: string;
|
||||
@ -982,6 +983,17 @@ export abstract class Invoice extends Transactional {
|
||||
return null;
|
||||
}
|
||||
|
||||
let linkedEntries;
|
||||
|
||||
if (this.returnAgainst) {
|
||||
const someDOC = (await this.fyo.doc.getDoc(
|
||||
ModelNameEnum.SalesInvoice,
|
||||
this.returnAgainst
|
||||
)) as SalesInvoice;
|
||||
|
||||
linkedEntries = await getLinkedEntries(someDOC);
|
||||
}
|
||||
|
||||
if (!this.stockNotTransferred) {
|
||||
return null;
|
||||
}
|
||||
@ -1005,6 +1017,7 @@ export abstract class Invoice extends Transactional {
|
||||
terms,
|
||||
numberSeries,
|
||||
backReference: this.name,
|
||||
returnAgainst: linkedEntries ? linkedEntries.Shipment![0] : '',
|
||||
};
|
||||
|
||||
let location = this.autoStockTransferLocation;
|
||||
|
@ -339,6 +339,7 @@ import LoyaltyProgramModal from './LoyaltyProgramModal.vue';
|
||||
import { POSItem, ItemQtyMap } from 'src/components/POS/types';
|
||||
import ItemsGrid from 'src/components/POS/Classic/ItemsGrid.vue';
|
||||
import ItemsTable from 'src/components/POS/Classic/ItemsTable.vue';
|
||||
import ReturnSalesInvoiceModal from './ReturnSalesInvoiceModal.vue';
|
||||
import MultiLabelLink from 'src/components/Controls/MultiLabelLink.vue';
|
||||
import { SalesInvoice } from 'models/baseModels/SalesInvoice/SalesInvoice';
|
||||
import SelectedItemTable from 'src/components/POS/Classic/SelectedItemTable.vue';
|
||||
@ -346,7 +347,6 @@ import WeightEnabledBarcode from 'src/components/Controls/WeightEnabledBarcode.v
|
||||
import FloatingLabelFloatInput from 'src/components/POS/FloatingLabelFloatInput.vue';
|
||||
import FloatingLabelCurrencyInput from 'src/components/POS/FloatingLabelCurrencyInput.vue';
|
||||
import { AppliedCouponCodes } from 'models/baseModels/AppliedCouponCodes/AppliedCouponCodes';
|
||||
import ReturnSalesInvoiceModal from './ReturnSalesInvoiceModal.vue';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'ClassicPOS',
|
||||
@ -451,6 +451,9 @@ export default defineComponent({
|
||||
eventName: PosEmits,
|
||||
...args: (string | boolean | Item | number | Money)[]
|
||||
) {
|
||||
console.log(eventName, 'eventName');
|
||||
console.log(...args, '...args');
|
||||
|
||||
this.$emit(eventName, ...args);
|
||||
},
|
||||
getItem,
|
||||
|
@ -50,6 +50,7 @@
|
||||
@save-invoice-action="saveInvoiceAction"
|
||||
@set-transfer-amount="setTransferAmount"
|
||||
@selected-invoice-name="selectedInvoiceName"
|
||||
@selected-return-invoice="selectedReturnInvoice"
|
||||
@set-transfer-clearance-date="setTransferClearanceDate"
|
||||
/>
|
||||
<ModernPOS
|
||||
@ -92,6 +93,7 @@
|
||||
@save-invoice-action="saveInvoiceAction"
|
||||
@set-transfer-amount="setTransferAmount"
|
||||
@selected-invoice-name="selectedInvoiceName"
|
||||
@selected-return-invoice="selectedReturnInvoice"
|
||||
@set-transfer-clearance-date="setTransferClearanceDate"
|
||||
/>
|
||||
</div>
|
||||
@ -398,6 +400,20 @@ export default defineComponent({
|
||||
});
|
||||
}
|
||||
},
|
||||
async selectedReturnInvoice(invoiceName: string) {
|
||||
const salesInvoiceDoc = (await this.fyo.doc.getDoc(
|
||||
ModelNameEnum.SalesInvoice,
|
||||
invoiceName
|
||||
)) as SalesInvoice;
|
||||
|
||||
let returnDoc = (await salesInvoiceDoc.getReturnDoc()) as SalesInvoice;
|
||||
|
||||
if (!returnDoc || !returnDoc.name) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.sinvDoc = returnDoc;
|
||||
},
|
||||
toggleView() {
|
||||
this.tableView = !this.tableView;
|
||||
},
|
||||
|
@ -20,13 +20,14 @@
|
||||
<div class="row-start-6 grid grid-cols-2 gap-4 mt-auto mb-2">
|
||||
<div class="col-span-2">
|
||||
<Button
|
||||
class="w-full bg-green-500"
|
||||
class="w-full bg-green-500 dark:bg-green-700"
|
||||
style="padding: 1.35rem"
|
||||
@click="$emit('selectedReturnInvoice', salesInvoiceName)"
|
||||
:disabled="!salesInvoiceName"
|
||||
@click="selectReturnInvoice"
|
||||
>
|
||||
<slot>
|
||||
<p class="uppercase text-lg text-white font-semibold">
|
||||
{{ t`Save` }}
|
||||
{{ t`Saved` }}
|
||||
</p>
|
||||
</slot>
|
||||
</Button>
|
||||
@ -36,7 +37,7 @@
|
||||
<div class="row-start-6 grid grid-cols-2 gap-4 mt-auto">
|
||||
<div class="col-span-2">
|
||||
<Button
|
||||
class="w-full bg-red-500"
|
||||
class="w-full bg-red-500 dark:bg-red-700"
|
||||
style="padding: 1.35rem"
|
||||
@click="$emit('toggleModal', 'ReturnSalesInvoice')"
|
||||
>
|
||||
@ -57,16 +58,13 @@ import Button from 'src/components/Button.vue';
|
||||
import Modal from 'src/components/Modal.vue';
|
||||
import { SalesInvoice } from 'models/baseModels/SalesInvoice/SalesInvoice';
|
||||
import { defineComponent, inject } from 'vue';
|
||||
import { t } from 'fyo';
|
||||
import Link from 'src/components/Controls/Link.vue';
|
||||
import FormControl from 'src/components/Controls/FormControl.vue';
|
||||
export default defineComponent({
|
||||
name: 'ReturnSalesInvoice',
|
||||
components: {
|
||||
Modal,
|
||||
Button,
|
||||
Link,
|
||||
FormControl,
|
||||
},
|
||||
emits: ['toggleModal', 'selectedReturnInvoice'],
|
||||
setup() {
|
||||
@ -82,7 +80,14 @@ export default defineComponent({
|
||||
methods: {
|
||||
updateCouponCode(invoiceName: string) {
|
||||
this.salesInvoiceName = invoiceName;
|
||||
console.log(this.salesInvoiceName, 'this.salesInvoiceName');
|
||||
},
|
||||
selectReturnInvoice() {
|
||||
console.log('selectReturnInvoiceselectReturnInvo');
|
||||
|
||||
this.$emit('selectedReturnInvoice', this.salesInvoiceName);
|
||||
this.$emit('toggleModal', 'ReturnSalesInvoice');
|
||||
|
||||
this.salesInvoiceName = '';
|
||||
},
|
||||
},
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user