Purchase orders
This commit is contained in:
parent
05755df998
commit
a45702cf26
|
|
@ -192,6 +192,7 @@ class _DesignEditState extends State<DesignEdit>
|
||||||
context: context,
|
context: context,
|
||||||
design: design,
|
design: design,
|
||||||
isDraftMode: _isDraftMode,
|
isDraftMode: _isDraftMode,
|
||||||
|
isPurchaseOrder: false,
|
||||||
onComplete: (response) async {
|
onComplete: (response) async {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isLoading = false;
|
_isLoading = false;
|
||||||
|
|
|
||||||
|
|
@ -1024,8 +1024,13 @@ class __PdfPreviewState extends State<_PdfPreview> {
|
||||||
final state = store.state;
|
final state = store.state;
|
||||||
final credentials = state.credentials;
|
final credentials = state.credentials;
|
||||||
final webClient = WebClient();
|
final webClient = WebClient();
|
||||||
String url =
|
String url = '${credentials.url}/live_preview';
|
||||||
'${credentials.url}/live_preview?entity=${invoice.entityType.snakeCase}';
|
|
||||||
|
if (invoice.isPurchaseOrder) {
|
||||||
|
url += '/purchase_order';
|
||||||
|
}
|
||||||
|
|
||||||
|
url += '?entity=${invoice.entityType.snakeCase}';
|
||||||
if (invoice.isOld) {
|
if (invoice.isOld) {
|
||||||
url += '&entity_id=${invoice.id}';
|
url += '&entity_id=${invoice.id}';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,19 +48,25 @@ class InvoiceEditPDFState extends State<InvoiceEditPDF> {
|
||||||
_isLoading = true;
|
_isLoading = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
final invoice = viewModel.invoice;
|
||||||
final credentials = viewModel.state.credentials;
|
final credentials = viewModel.state.credentials;
|
||||||
final webClient = WebClient();
|
final webClient = WebClient();
|
||||||
String url =
|
String url = '${credentials.url}/live_preview';
|
||||||
'${credentials.url}/live_preview?entity=${viewModel.invoice.entityType.snakeCase}';
|
|
||||||
if (viewModel.invoice.isOld) {
|
if (invoice.isPurchaseOrder) {
|
||||||
url += '&entity_id=${viewModel.invoice.id}';
|
url += '/purchase_order';
|
||||||
|
}
|
||||||
|
|
||||||
|
url += '?entity=${invoice.entityType.snakeCase}';
|
||||||
|
|
||||||
|
if (invoice.isOld) {
|
||||||
|
url += '&entity_id=${invoice.id}';
|
||||||
}
|
}
|
||||||
if (viewModel.state.isHosted) {
|
if (viewModel.state.isHosted) {
|
||||||
url = url.replaceFirst('//', '//preview.');
|
url = url.replaceFirst('//', '//preview.');
|
||||||
}
|
}
|
||||||
|
|
||||||
final data =
|
final data = serializers.serializeWith(InvoiceEntity.serializer, invoice);
|
||||||
serializers.serializeWith(InvoiceEntity.serializer, viewModel.invoice);
|
|
||||||
webClient
|
webClient
|
||||||
.post(url, credentials.token,
|
.post(url, credentials.token,
|
||||||
data: json.encode(data), rawResponse: true)
|
data: json.encode(data), rawResponse: true)
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ class _InvoiceDesignState extends State<InvoiceDesign>
|
||||||
FormCard(
|
FormCard(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (state.isProPlan) ...[
|
if (state.isProPlan || state.isTrial) ...[
|
||||||
if (company.isModuleEnabled(EntityType.invoice)) ...[
|
if (company.isModuleEnabled(EntityType.invoice)) ...[
|
||||||
DesignPicker(
|
DesignPicker(
|
||||||
label: localization.invoiceDesign,
|
label: localization.invoiceDesign,
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ void loadDesign({
|
||||||
@required BuildContext context,
|
@required BuildContext context,
|
||||||
@required DesignEntity design,
|
@required DesignEntity design,
|
||||||
@required bool isDraftMode,
|
@required bool isDraftMode,
|
||||||
|
@required bool isPurchaseOrder,
|
||||||
@required Function(Response) onComplete,
|
@required Function(Response) onComplete,
|
||||||
}) {
|
}) {
|
||||||
if (Config.DEMO_MODE) {
|
if (Config.DEMO_MODE) {
|
||||||
|
|
@ -32,6 +33,10 @@ void loadDesign({
|
||||||
final credentials = state.credentials;
|
final credentials = state.credentials;
|
||||||
String url = '${credentials.url}/preview';
|
String url = '${credentials.url}/preview';
|
||||||
|
|
||||||
|
if (isPurchaseOrder) {
|
||||||
|
url += '/purchase_order';
|
||||||
|
}
|
||||||
|
|
||||||
if (isDraftMode) {
|
if (isDraftMode) {
|
||||||
url += '?html=true';
|
url += '?html=true';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue